繁体   English   中英

PHPMailer SMTP错误:命令失败

[英]PHPMailer SMTP ERROR: command failed

我使用gmail的主机时,我的代码有效,但是对于该项目,我必须使用office365.com,并且收到错误消息,我不知道该怎么做:

$mail = new PHPMailer;
    $mail->IsSMTP();  // telling the class to use SMTP
    $mail->SMTPAuth   = true;           // enable SMTP authentication
    $mail->IsHTML(true);

    $mail->Host     = "smtp.office365.com";         // SMTP server
    $mail->SMTPSecure = "tls";                      // sets the prefix to the servier
    $mail->Port       = 587;                        // set the SMTP port for the GMAIL 
    $mail->Username   = "username";     // username
    $mail->Password   = "password";             // password

    //works with this (gmail)
    //$mail->Host     = "smtp.gmail.com"; // SMTP server
    //$mail->SMTPSecure = "tls";          // sets the prefix to the servier
    //$mail->Port       = 587;            // set the SMTP port for the GMAIL 
    //$mail->Username   = "username";  // GMAIL username
    //$mail->Password   = "password";            // GMAIL password

    $mail->setFrom('someEmailAdress');
    $mail->addReplyTo("someEmailAdress");

    $mail->AddAddress('someEmailAdress');

    $mail->Subject  = $_POST['ActivityType']." ".$_POST['DealerName'];
    $mail->Body     = $message;
    $mail->WordWrap = 400;
    $mail->IsHTML(true);
    $mail->SMTPDebug = 2;    
    $mail->Send();

这是我得到的错误

12014-12-22 18:15:39    SERVER -> CLIENT: 220 BY2PR05CA022.outlook.office365.com
    Microsoft ESMTP MAIL Service ready at Mon, 22 Dec 2014 18:15:39 +0000
2014-12-22 18:15:39 CLIENT -> SERVER: EHLO 192.168.1.53
2014-12-22 18:15:39 SERVER -> CLIENT: 250-BY2PR05CA022.outlook.office365.com Hello [24.37.210.58]

250-SIZE 78643200

250-PIPELINING

250-DSN

250-ENHANCEDSTATUSCODES

250-STARTTLS

250-8BITMIME

250-BINARYMIME

250 CHUNKING
2014-12-22 18:15:39 CLIENT -> SERVER: STARTTLS
2014-12-22 18:15:39 SERVER -> CLIENT: 220 2.0.0 SMTP server ready
2014-12-22 18:15:39 CLIENT -> SERVER: QUIT
2014-12-22 18:15:40 SERVER -> CLIENT:
2014-12-22 18:15:40 SMTP ERROR: QUIT command failed:
SMTP connect() failed

已经尝试找出发生了什么情况,但是由于quit命令的“一般”错误失败,实际上没有太多可搜索的内容。 特别是当gmail工作正常时,它是否可以在Office365方面使用?

btw Outlook是其中最受限制的,特别是涉及到html电子邮件,这是您在ur选项中设置的,首先尝试发送到gmail之类的邮件,也许是yahoo,但它又有一些限制,但是gmail每次都能正常工作而没有任何问题,您还可以使用fakesmtp之类的东西来捕获已发送的电子邮件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM