【发布时间】:2014-03-14 09:48:46
【问题描述】:
我必须通过 Gmail 发送邮件,但我不知道如何配置 phpmailer。
当我使用phpmailer 时,它给了我一个尚未经过身份验证但电子邮件和密码正确的错误。
代码如下:
require '../class.phpmailer.php';
try {
$mail = new PHPMailer(true); //New instance, with exceptions enabled
$body = file_get_contents('contents.html');
$body = preg_replace('/\\\\/','', $body); //Strip backslashes
$mail->IsSMTP(); // tell the class to use SMTP
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Port = 25; // set the SMTP server port
$mail->Host = "smtp.gmail.com"; // SMTP server
$mail->Username = "yuliy.x.95@gmail.com"; // SMTP server username
$mail->Password = "mypassword"; // SMTP server password
$mail->IsSendmail(); // tell the class to use Sendmail
$mail->AddReplyTo("k.yuliy@yahoo.it","First Last");
$mail->From = "name@domain.com";
$mail->FromName = "First Last";
$to = "k.yuliy@yahoo.it";
$mail->AddAddress($to);
$mail->Subject = "First PHPMailer Message";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->WordWrap = 80; // set word wrap
$mail->MsgHTML($body);
$mail->IsHTML(true); // send as HTML
$mail->Send();
echo 'Message has been sent.';
} catch (phpmailerException $e) {
echo $e->errorMessage();
}
?>
我收到此错误:
无法执行:/var/qmail/bin/sendmail
【问题讨论】:
-
你看过any of these吗?
-
服务器的操作系统是什么?