dtwknzk3764
2012-05-18 16:39
浏览 55
已采纳

无法通过PHPMailer发送邮件

This is my php code

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! 

 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.';
}

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

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

My error is

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......

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

4条回答 默认 最新

  • dongying9756 2012-05-18 16:42
    已采纳

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

    已采纳该答案
    评论
    解决 无用
    打赏 举报
  • dongsheng9203 2012-05-18 16:53
    评论
    解决 无用
    打赏 举报
  • duanhuantong8278 2013-01-24 02:57

    Change your host to

    ssl://smtp.gmail.com:465
    
    评论
    解决 无用
    打赏 举报
  • dongzhi1950 2013-08-14 14:04

    firstly be sure you have the last version of phpmailer()

    download it from https://github.com/PHPMailer/PHPMailer

    open class.phpmailer.php by php editor

    replace all "HELO" words to "EHLO"

    EHLO (not HELO) must be given by client before AUTH. (FOR GOOGLE MAIL)

    it will be solved.

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题