【问题标题】:SMTP Email Send Issue by using PHPMailer使用 PHPMailer 的 SMTP 电子邮件发送问题
【发布时间】:2022-01-24 10:46:08
【问题描述】:

我是新来的。我最近遇到了来自我的 Windows 服务器的电子邮件发送问题。 50% 的情况下邮件无法发送用户。 下面显示错误消息

*******Password not accepted from server: 421 4.7.66 TLS 1.0 and 1.1 are not supported. Please upgrade/update your client to support TLS 1.2. Visit https://aka.ms/smtp_auth_tls. [SI2P153CA0009.APCP153.PROD.OUTLOOK.COM]******* 

This is my Mail Server Configuration code :

<?php
//require_once('class.phpmailer.php');
//date_default_timezone_set('PRC'); //Set China time zone 
date_default_timezone_set('Asia/Dhaka');
$mail = new PHPMailer(); //Instantiate
$mail->SetLanguage("en", 'language.php');
$mail->SMTPDebug = 4; 
$mail->SetLanguage("en");
$mail->IsSMTP(); //  Enable SMTP
$mail->SMTPAuth   = true;  //Enable SMTP authentications
$mail->SMTPSecure = 'tls';  
$mail->Host = "Smtp.office365.com"; //SMTP server Take 163 mailbox as an example
$mail->Port = 587;  //Mail sending port
$mail->Username = "UserName";  //your mailbox
$mail->Password = "Password";  //Your password

?>

我已安装 Visual Studio 2022 用于升级 .NET 框架。 你能告诉我如何解决问题吗?

【问题讨论】:

    标签: visual-studio smtp office365 phpmailer .net-framework-4.8


    【解决方案1】:

    当出现错误消息时,您应该始终做的第一件事是阅读它

    TLS 1.0 and 1.1 are not supported. Please upgrade/update your client to support TLS 1.2. Visit https://aka.ms/smtp_auth_tls
    

    这表明您的服务器,或者至少是您在其上运行的 PHP 版本严重过时。最重要的是,我可以看到您正在使用一个非常旧且不受支持的 PHPMailer 版本,所以upgrade

    【讨论】:

    • 谢谢兄弟,我已经更新了我的代码,现在可以正常工作了
    【解决方案2】:

    终于解决了。我更新了我的代码并使用最新的 PHPMailler 版本。现在收到 100% 的邮件。下面的代码对我有用..

    <?php
    
    require 'includes/PHPMailer.php';
    require 'includes/SMTP.php';
    require 'includes/Exception.php';
    
    use PHPMailer\PHPMailer\PHPMailer;
    use PHPMailer\PHPMailer\SMTP;
    use PHPMailer\PHPMailer\Exception;
    
    $mail = new PHPMailer(); //Instantiate
    $mail->isSMTP(); //  Enable SMTP
    $mail->Host = "Smtp.office365.com"; //SMTP
    $mail->SMTPAuth = "true";  //Enable SMTP authentications
    $mail->SMTPSecure = "tls"; 
    $mail->Port = "587";  //Mail sending port
    $mail->Username = "Username";  //your mailbox
    $mail->Password = "Password";  //Your
    

    ?>

    【讨论】:

    • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
    猜你喜欢
    • 1970-01-01
    • 2011-04-06
    • 2017-10-05
    • 1970-01-01
    • 1970-01-01
    • 2017-12-23
    • 1970-01-01
    • 2014-06-23
    • 2014-10-19
    相关资源
    最近更新 更多