无法通过PHPMailer发送邮件 [英] Can not send mail through PHPMailer

查看:87
本文介绍了无法通过PHPMailer发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的php代码

require("class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP();  // telling the class to use SMTP
$mail->Host     = "smtp.gmail.com"; // SMTP server

$mail->From     = "example@gmail.com";
$mail->AddAddress("example@yahoo.com");

$mail->Subject  = "First PHPMailer Message";
$mail->Body     = "Hi! \n\n This is my first e-mail sent through PHPMailer.";
$mail->WordWrap = 50;

if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
}

我的php.ini具有此邮件配置 [邮件功能]

My php.ini has this mail configuration [mail function]

SMTP = smtp.gmail.com
smtp_port = 465
sendmail_from =example@gmail.com

我的错误是

以下发件人地址失败:example@gmail.com消息未发送 发送邮件 错误:以下发件人地址失败:example@gmail.com SMTP服务器错误:5.7.0必须首先发出STARTTLS命令. i1sm13250552pbv.49

The following From address failed: example@gmail.com Message was not sent.Mailer error: The following From address failed: example@gmail.com SMTP server error: 5.7.0 Must issue a STARTTLS command first. i1sm13250552pbv.49

请帮助我.谢谢...

please help me.thanks in advance......

推荐答案

smtp.gmail.com要求您使用SSL和端口587或465.

smtp.gmail.com requires that you use SSL and port 587 or 465.

这篇关于无法通过PHPMailer发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆