无法通过PHP验证SMTP

Rituparno Bhattacharya

我无法使用PHPMailer从PHP发送邮件。以前我是通过VB.NET尝试过的,但效果很好。尝试时,它使我跌破错误-

2019-05-13 15:15:46 Connection: opening to smtp-gw.abcd.com:25, timeout=300, options=array ( 'ssl' => array ( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true, ),)
2019-05-13 15:15:46 Connection: opened
2019-05-13 15:15:46 SMTP INBOUND: "220 Mail02.abcd.com ESMTP"
2019-05-13 15:15:46 SERVER -> CLIENT: 220 Mail02.abcd.com ESMTP
2019-05-13 15:15:46 CLIENT -> SERVER: EHLO localhost
2019-05-13 15:15:46 SMTP INBOUND: "250-Mail02.abcd.com"
2019-05-13 15:15:46 SMTP INBOUND: "250-8BITMIME"
2019-05-13 15:15:46 SMTP INBOUND: "250-SIZE 104857600"
2019-05-13 15:15:46 SMTP INBOUND: "250 STARTTLS"
2019-05-13 15:15:46 SERVER -> CLIENT: 250-Mail02.abcd.com250-8BITMIME250-SIZE 104857600250 STARTTLS
2019-05-13 15:15:46 CLIENT -> SERVER: STARTTLS
2019-05-13 15:15:46 SMTP INBOUND: "220 Go ahead with TLS"
2019-05-13 15:15:46 SERVER -> CLIENT: 220 Go ahead with TLS
2019-05-13 15:15:46 CLIENT -> SERVER: EHLO localhost
2019-05-13 15:15:46 SMTP INBOUND: "250-Mail02.abcd.com"
2019-05-13 15:15:46 SMTP INBOUND: "250-8BITMIME"
2019-05-13 15:15:46 SMTP INBOUND: "250 SIZE 104857600"
2019-05-13 15:15:46 SERVER -> CLIENT: 250-Mail02.abcd.com250-8BITMIME250 SIZE 104857600
SMTP Error: Could not authenticate.
2019-05-13 15:15:46 CLIENT -> SERVER: QUIT
2019-05-13 15:15:46 SMTP INBOUND: "221 Mail02.abcd.com"
2019-05-13 15:15:46 SERVER -> CLIENT: 221 Mail02.abcd.com
2019-05-13 15:15:46 Connection: closed
SMTP Error: Could not authenticate.
Message could not be sent. Mailer Error: SMTP Error: Could not authenticate.

这是我的代码块-

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

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

// Instantiation and passing `true` enables exceptions
$mail = new PHPMailer(true);

try {
    //Server settings
    $mail->SMTPDebug = 4;                                       // Enable verbose debug output
    $mail->isSMTP();                                            // Set mailer to use SMTP
    $mail->Host       = 'smtp-gw.abcd.com';  // Specify main and backup SMTP servers
    $mail->SMTPAuth   = true;                                   // Enable SMTP authentication
    $mail->Username   = '[email protected]';                     // SMTP username
    $mail->Password   = '';                               // SMTP password
    $mail->SMTPSecure = 'tls';                                  // Enable TLS encryption, `ssl` also accepted
    $mail->Port       = 25;                                    // TCP port to connect to
    $mail->SMTPOptions = array(
    'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
    )
);

我不太确定我在这里缺少什么。我知道此SMTP服务器身份验证没有任何密码。您也可以在.NET代码中进行检查。这是我的VB.NET代码

 Dim Smtp_Server As New SmtpClient
            Dim e_mail As New MailMessage()
            Smtp_Server.UseDefaultCredentials = False
            Smtp_Server.Credentials = New Net.NetworkCredential("[email protected]", "")
            Smtp_Server.Port = 25
            Smtp_Server.EnableSsl = False
            Smtp_Server.Host = "smtp-gw.abcd.com"

在这方面寻求帮助。

同步

服务器说它在STARTTLS之前或之后都不支持身份验证,即AUTH在任何EHLO一条命令之后都没有出现在服务器功能列表中例如,这是gmail所说的:

250-smtp.gmail.com at your service, [88.184.221.3]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8

由于您的服务器似乎不允许身份验证(并且您的VB脚本可能会发现身份并且不愿意尝试),因此请告诉您的脚本不要使用它:

$mail->SMTPAuth   = false;                                   // Enable SMTP authentication
$mail->Username   = '';                     // SMTP username
$mail->Password   = '';                               // SMTP password

另外,为什么要禁用TLS证书验证?你需要有一个非常充分的理由这样做-而不仅仅是“使它工作”; 如果您的TLS配置损坏,请修复它,而不仅仅是抑制错误。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Jenkins SMTP电子邮件配置无法通过验证

无法使用cram_md5身份验证通过SMTP通过SMTP发送电子邮件

PHP Mailer返回PHP致命错误:未捕获PHPMailer \ PHPMailer \ Exception:SMTP错误:无法验证

SMTP错误:无法验证。无法发送信息。邮件错误:SMTP错误:无法验证

无法通过发送网格smtp发送邮件。

mail(): 无法连接到 "localhost" 端口 25 的邮件服务器,请验证 php.ini 中的 "SMTP" 和 "smtp_port" 设置或使用 ini_set()

无法通过密码验证Android

无法通过“功能”验证数据

无法通过Django通过SendGrid验证

无法通过API或SMTP通过Mailgun发送邮件

苹果邮件显示“无法验证smtp.gmail.com的身份”

无法连接到 GMail SMTP (PHPMailer) - 证书验证失败

为什么我无法通过此AJAX和PHP验证获得预期的结果

AWS SES与使用SMTP,SMTP的PHPMailer的错误:无法进行身份验证?

使用PHP mail()函数进行SMTP身份验证

无法通过GoDaddy SMTP发送电子邮件

无法通过 SMTP yandex 错误 553 发送邮件

PHP验证无法正常工作

无法验证Webhook签名PHP

验证无法通过Spring Boot进入mongoDB

pip始终无法通过ssl验证

无法验证通过 Xunit Mock 调用的方法

存储库无法通过身份验证

vsftpd无法通过pam身份验证

Flask WTF-Form无法通过验证

无法通过JavaScript验证我的“代码”

无法通过Recaptcha获取图像验证

XML文档无法通过XSD验证

无法通过“ openssl验证”来加密证书