【问题标题】:SMTP: CLIENT: 535 5.7.3 Authentication UnsuccessfulSMTP:客户端:535 5.7.3 身份验证不成功
【发布时间】:2019-01-26 11:29:10
【问题描述】:

每当有人在我的网站上输入表单但SMTP 不起作用时,我都会尝试发送电子邮件。它不断向我显示此错误。电子邮件帐户的凭据是正确的。另外,我已经尝试过SMTPAuth = False;,但结果还是一样。

<?php
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];  


    // Import PHPMailer classes into the global namespace
    // These must be at the top of your script, not inside a function
    use PHPMailer\PHPMailer\PHPMailer;
    use PHPMailer\PHPMailer\Exception;

    //Load Composer's autoloader
    require 'vendor/autoload.php';

    $mail = new PHPMailer(true);                              
    try {
        //Server settings
        $mail->SMTPDebug = 2;                                
        $mail->isSMTP();                                 
        $mail->Host = 'smtp.office365.com';  
        $mail->Port = 587;                               
        $mail->SMTPSecure = 'TLS';        
        $mail->SMTPAuth = true;                               
        $mail->Username = 'sender@test.com';                 // SMTP username
        $mail->Password = 'password';                        // SMTP password


        //Recipients
        $mail->setFrom('test@test.com', ' Services');
        $mail->addAddress('recipient@test.com', $name);     // Add a recipient


        //Content
        $mail->isHTML(true);                       // Set email format to HTML
        $mail->Subject = 'Contact Us Message';
        $mail->Body    = 'Sent a message, This is the message :';
        $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

        $mail->send();
        header('Location: tempage.php');
    } catch (Exception $e) {
        echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
    }
?> 

出了什么问题?感谢您的帮助。

【问题讨论】:

    标签: php html smtp


    【解决方案1】:

    我也在同样的问题上苦苦挣扎了 2 天。 在我找到这个解决方案之后。它工作正常。 试试这个。

    $mail->Host = 'smtp.office365.com'; 改成 $mail->Host = 'smtp.live.com';

    【讨论】:

      猜你喜欢
      • 2016-01-19
      • 1970-01-01
      • 2018-01-07
      • 2021-10-13
      • 2022-11-22
      • 2013-08-07
      • 1970-01-01
      • 2023-02-08
      • 2016-08-20
      相关资源
      最近更新 更多