我有這樣一段代碼:PHPMailer的與SMTP
ini_set('SMTP','smtp.strato.com');
$mail = new PHPmailer();
$mail->IsHTML(true);
它工作正常,但我可以在PHPMailer的類中設置smtp.strato.com地方?
我有這樣一段代碼:PHPMailer的與SMTP
ini_set('SMTP','smtp.strato.com');
$mail = new PHPmailer();
$mail->IsHTML(true);
它工作正常,但我可以在PHPMailer的類中設置smtp.strato.com地方?
你看過他們網站上的smtp例子嗎? See here
除非我很想理解你,否則它看起來很直截了當。
$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!";
}
你可以通過改變
到
$mail->IsSMTP();
$mail->Host = "smtp.strato.com";
你不應該修改的PHPMailer類
//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;
?>
有很多'PHPmailer'班左右。你從哪裏得到這個? – xzyfer 2011-03-04 12:02:47
@xzyfer www.worxware.com – Muiter 2011-03-04 13:51:46
「你在phpMailer中的某處設置」是什麼意思? – xzyfer 2011-03-04 14:41:20