Outlook中的PHPMailer中出现“ SMTP错误:无法验证”

时间:2018-09-07 08:47:20

标签: php outlook smtp phpmailer

我在用于通过office360发送电子邮件的简单脚本中使用PHPMailer,但出现“未知错误”

SMTP->错误:服务器不接受密码: SMTP->错误:RSET失败:235 2.7.0身份验证成功的目标主机PS1PR06MB1083.apcprd06.prod.outlook.com SMTP错误:无法验证。邮件错误:SMTP错误:无法验证。 SMTP服务器错误:2.7.0身份验证成功,目标主机PS1PR06MB1083.apcprd06.prod.outlook.com

<?php
    //error_reporting(E_ALL);
    error_reporting(E_STRICT);

    date_default_timezone_set('America/Toronto');

    require_once('class.phpmailer.php');
    include("class.smtp.php"); // optional, gets called from within 
    class.phpmailer.php if not already loaded

    $mail             = new PHPMailer();
    $mail->CharSet = 'UTF-8';
    if(isset($_POST['upload']))
      {
    $name = $_REQUEST['name'] ;
    $email = $_REQUEST['email'] ;
    $message = $_REQUEST['comments'] ;
     //$body             = file_get_contents('contents.html');
     //$body             = eregi_replace("[\]",'',$body);

    $mail->IsSMTP(); // telling the class to use SMTP
    $mail->Host       = "smtp.office365.com"; // SMTP server
    $mail->SMTPDebug  = 1;                     // enables SMTP debug information 
    (for testing)
                                           // 1 = errors and messages
    $mail->SMTPSecure = "tls";                                    // 2 = 
     messages only
    $mail->SMTPAuth   = true;                  // enable SMTP authentication
    $mail->Host       = "smtp.office365.com"; // sets the SMTP server
    $mail->Port       = 587;                    // set the SMTP port for the 
    GMAIL server
    $mail->Username   = "no-reply@outlook.ac.in"; // SMTP account username
    $mail->Password   = "outlookpassword";        // SMTP accountlt password

    $mail->SetFrom('no-reply@outlook.ac.in', 'First Last');
    $mail->AddReplyTo("aaa@outlook.ac.in","First Last");

    $mail->Subject    = "Website Feedback";

    $mail->AltBody    = $comments; // optional, comment out and test
    $body = "Dear Sir  !

    Name of the Candidate : $name <br/>
    Email id : $email <br/>
    Comments : $message"; 
    $mail->MsgHTML($body);

    $address = "aaaa@outlook.ac.in";
    $mail->AddAddress($address, "aaa");
    //$mail->AddAttachment("images/phpmailer.gif");      // attachment
    //$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment

    if(!$mail->Send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
    } else {
      echo "Message sent! Thank you for your feedback.";
     }
    }
    else {
    echo "data is empty";
     }
    ?> `

0 个答案:

没有答案