2011-03-04 6 views
1

J'ai ce morceau de code:phpMailer avec smtp

ini_set('SMTP','smtp.strato.com'); 
$mail = new PHPmailer(); 
$mail->IsHTML(true); 

Il fonctionne très bien, mais je peux mettre smtp.strato.com quelque part dans la classe phpMailer?

+0

Il y a beaucoup 'classes PHPmailer' autour. D'où avez-vous pris celui-ci? – xzyfer

+0

@xzyfer www.worxware.com – Muiter

+0

Que voulez-vous dire par "définir quelque part dans phpMailer"? – xzyfer

Répondre

4

Avez-vous regardé l'exemple de smtp sur leur site? See here

À moins que je ne te comprenne pas, ça semble être très simple.

$mail    = new PHPMailer(); 

$body    = "message"; 

$mail->IsSMTP(); // telling the class to use SMTP 
$mail->Host  = "mail.yourdomain.com"; // SMTP server 
$mail->SMTPAuth = true;     // enable SMTP authentication 
$mail->Host  = "mail.yourdomain.com"; // sets the SMTP server 
$mail->Port  = 26;     // set the SMTP port for the GMAIL server 
$mail->Username = "[email protected]"; // SMTP account username 
$mail->Password = "yourpassword";  // SMTP account password 

$mail->SetFrom('[email protected]', 'First Last'); 
$mail->AddReplyTo("[email protected]","First Last"); 
$mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication"; 
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test 
$mail->MsgHTML($body); 

$mail->AddAddress("[email protected]", "John Doe"); 

if(!$mail->Send()) { 
    echo "Mailer Error: " . $mail->ErrorInfo; 
} else { 
    echo "Message sent!"; 
} 
0

Vous pouvez en changeant

$mail->IsSMTP(); 
    $mail->Host  = "mail.yourdomain.com"; 

à

$mail->IsSMTP(); 
    $mail->Host  = "smtp.strato.com"; 

vous ne devriez pas modifier la classe PHPMailer

0
//Use this codd to send email using SMTP gmail  
<?php 
require "PHPMailer/PHPMailerAutoload.php"; 
$mail = new PHPMailer(); 
$mail->IsSMTP(); 
$mail->Host = "smtp.gmail.com"; 
$mail->Port = 465; 
$mail->SMTPAuth="login"; 
$mail->SMTPSecure="ssl"; 
$mail->Username = "[email protected]"; 
$mail->Password="password"; 
$mail->Body="<Body message>"; 
$mail->MsgHTML=("<h1>Wow Html contents</h1>"); 
$mail->AddAttachment("Koala.jpg"); 
$mail->SetFrom("[email protected]","Bucky"); 
$mail->Subject="My Subject"; 
$mail->AddAddress("[email protected]"); 

if ($mail->Send()){ 
    echo "Sent"; 
}else 
    echo "not sent<br>"; 
    echo $mail->ErrorInfo; 

?> 
Questions connexes