首页 > 解决方案 > WP Mail SMTP 版本 1.5.1 不发送测试邮件

问题描述

我已经在我的 wordpress 站点中配置了 WP Mail SMTP 插件,但配置后我正在测试插件是否工作,在测试它时给出 bel;low 错误:

add_action( 'phpmailer_init', 'reconfigure_smtp' );
function reconfigure_smtp( $phpmailer ) {
    $SMTPhost = get_option('smtp_host');
    $SMTPport = get_option('smtp_port');
    $FromEmail = get_option('mail_from');
    $FromName = get_option('mail_from_name');
    $phpmailer->isSMTP();     
    $phpmailer->Host =$SMTPhost;
    $phpmailer->Port = $SMTPport;
    $phpmailer->From = $FromEmail;
    $phpmailer->FromName = $FromName;
}

单击此处查看完整的错误日志以进行调试:

WordPress: 5.1.1
WordPress MS: No
PHP: 7.0.33-5+ubuntu18.04.1+deb.sury.org+1
WP Mail SMTP: 1.4.2

Params:
Mailer: smtp
Constants: No
ErrorInfo: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Host: smtp.gmail.com
Port: 465
SMTPSecure: ssl
SMTPAutoTLS: bool(true)
SMTPAuth: bool(true)

Server:
OpenSSL: OpenSSL 1.1.1b 26 Feb 2019
Apache.mod_security: No
SMTP Debug:
2019-07-16 09:54:17 Connection: opening to ssl://smtp.gmail.com:465, timeout=300, options=array (
)
2019-07-16 09:54:17 Connection: opened
2019-07-16 09:54:17 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP g35sm11776763qtg.92 - gsmtp
2019-07-16 09:54:17 CLIENT -> SERVER: EHLO www.ZZZZZ.com
2019-07-16 09:54:17 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [34.200.115.143]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
2019-07-16 09:54:17 CLIENT -> SERVER: AUTH LOGIN
2019-07-16 09:54:17 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2019-07-16 09:54:17 CLIENT -> SERVER: Y29udGFjdGFoZXhAZ21haWwuY29t
2019-07-16 09:54:17 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2019-07-16 09:54:17 CLIENT -> SERVER: YTFoMmUzeDRAIyQ=
2019-07-16 09:54:18 SERVER -> CLIENT: 534-5.7.14 Please
534-5.7.14 log in via your web browser and then try again.
534-5.7.14 Learn more at
534 5.7.14 https://support.google.com/mail/answer/78754 g35sm11776763qtg.92 - gsmtp
2019-07-16 09:54:18 SMTP ERROR: Password command failed: 534-5.7.14 Please
534-5.7.14 log in via your web browser and then try again.
534-5.7.14 Learn more at
534 5.7.14 https://support.google.com/mail/answer/78754 g35sm11776763qtg.92 - gsmtp
2019-07-16 09:54:18 SMTP Error: Could not authenticate.
2019-07-16 09:54:18 CLIENT -> SERVER: QUIT
2019-07-16 09:54:18 SERVER -> CLIENT: 221 2.0.0 closing connection g35sm11776763qtg.92 - gsmtp
2019-07-16 09:54:18 Connection: closed
2019-07-16 09:54:18 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

发送测试电子邮件时出现问题。

无法连接到 SMTP 主机。

这意味着您的网络服务器无法连接到 smtp.gmail.com。

通常由于以下原因之一返回此错误:

-SMTP 设置不正确(端口错误、安全设置、主机不正确)。- 您的网络服务器正在阻止连接。- 您的 SMTP 主机拒绝连接。

建议的后续步骤:三重检查您的 SMTP 设置,包括主机地址、电子邮件和密码、端口和安全性。请联系您的网络托管服务提供商并要求他们验证您的服务器是否可以使用 tls 加密在端口 587 上连接到 smtp.gmail.com。此外,询问他们是否有防火墙或安全策略阻止了连接——许多共享主机阻止了某些端口。注意:这是导致此问题的最常见原因。请联系您的 SMTP 主机以确认您使用的是正确的用户名和密码。与您的 SMTP 主机确认您的帐户有权使用外部连接发送电子邮件。

标签: phpwordpresssmtpwordpress-themingphpmailer

解决方案


首先需要检查 SMTP 详细信息,例如(SMTP 主机、加密、SMTP 用户名和 SMTP 密码),然后需要在我们的 gmail 或 yahoo 设置中启用不太安全的应用程序。


推荐阅读