我有这样一段代码: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