【问题标题】:Failed to authenticate on SMTP server with username "yea****" using 2 possible authenticators无法使用 2 个可能的身份验证器在用户名“yea****”的 SMTP 服务器上进行身份验证
【发布时间】:2019-01-20 02:28:49
【问题描述】:

我正在尝试使用 SendGrid 为 Laravel 项目设置电子邮件。 遵循他们的文档时,我收到一个错误 (https://sendgrid.com/docs/Integrate/Frameworks/laravel.html)

.env 看起来像这样

MAIL_DRIVER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=yea****
MAIL_PASSWORD=*********
MAIL_ENCRYPTION=tls
MAIL_FROM_NAME="John Smith"
MAIL_FROM_ADDRESS=from@example.com

我得到的错误是这样的

ErrorException (E_WARNING)
stream_socket_enable_crypto(): Peer certificate CN=`****.****.***' did not match expected CN=`smtp.sendgrid.net'


/home/myusername/public_html/api/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php
    public function startTLS()
            {
                // STREAM_CRYPTO_METHOD_TLS_CLIENT only allow tls1.0 connections (some php versions)
                // To support modern tls we allow explicit tls1.0, tls1.1, tls1.2
                // Ssl3 and older are not allowed because they are vulnerable
                // @TODO make tls arguments configurable
                return stream_socket_enable_crypto($this->stream, true, STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT);
            }

        Arguments
        "stream_socket_enable_crypto(): Peer certificate CN=`****.****.***' did not match expected CN=`smtp.sendgrid.net'"

我使用此答案 (https://stackoverflow.com/a/45315825) 中提供的代码修复了此错误。 我知道这是不好的做法,但我遇到了另一个错误。

Swift_TransportException
Failed to authenticate on SMTP server with username "yea****" using 2 possible authenticators. Authenticator LOGIN returned Swift_TransportException: Expected response code 235 but got code "535", with message "535 Incorrect authentication data " in /home/myusername/public_html/a[i/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:456 Stack trace: #0 

/home/myusername/public_html/api/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php
$message = 'Failed to authenticate on SMTP server with username "'.$this->username.'" using '.$count.' possible authenticators.';
            foreach ($errors as $error) {
                $message .= ' Authenticator '.$error[0].' returned '.$error[1].'.';
            }
            throw new Swift_TransportException($message);
        }
    }

这对我来说似乎是某种身份验证错误,我使用的凭据与登录 SendGrid 仪表板时使用的凭据相同。

关于如何解决这些问题的任何想法?

【问题讨论】:

  • 您使用什么作为托管服务提供商?
  • 我在TransIp使用cPanel VPS

标签: laravel email sendgrid laravel-5.6


【解决方案1】:

我对这种情况的解决方案是用双引号括起用户名、密码和端口号。

然后我得到另一个错误,像这样:

''' 连接到 tcp://smtp.hostx.com:465 超时 '''

   Connection to tcp://smtp.hostx.com:465 Timed Out

我修复了它,将 MAIL_ENCRYPTION 从 tls 更改为 ssl

MAIL_ENCRYPTION=ssl

我希望这对其他人有帮助,因为这篇文章太旧了。

【讨论】:

    猜你喜欢
    • 2021-06-11
    • 2018-01-13
    • 2019-10-06
    • 1970-01-01
    • 1970-01-01
    • 2020-12-21
    • 2019-10-02
    • 2019-09-16
    • 1970-01-01
    相关资源
    最近更新 更多