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

brc7rcf0  于 2023-03-07  发布在  PHP
关注(0)|答案(1)|浏览(237)

我正在使用PHPMailer在一个简单的脚本发送电子邮件的通过office360,我得到一个"未知错误"

    • SMTP-〉错误:不接受来自服务器的密码:SMTP-〉错误:RSET失败:235 2.7.0验证成功目标主机www.example.com SMTP错误:PS1PR06MB1083.apcprd06.prod.outlook.comSMTP错误:无法验证。SMTP服务器错误:2.7.0验证成功目标主机PS1PR06MB1083.apcprd06.prod.outlook.comCould not authenticate. SMTP server error: 2.7.0 Authentication successful target host 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";
     }
    ?> `
eulz3vhy

eulz3vhy1#

你可以尝试下面的评论:

//$mail->isSMTP(true);

相关问题