Laravel smt 未能使用以下身份验证器对 SMTP 进行身份验证:"CRAM-MD5"、"LOGIN"、"PLAIN"



我正在尝试在laravel 9应用程序中设置smtp邮件,但我无法使其工作。

我在在线smtp测试仪中使用的设置(工作良好)是:

host:mail.****.**
post:587
Use secured connection: no
Use authentication: yes
login credentials...

mail.php文件中:

'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'encryption' => null,//env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'auth_mode'  => null,
'verify_peer' => false,
],

并且在.env文件中:

MAIL_MAILER=smtp
MAIL_HOST=mail.*****.**
MAIL_PORT=587
MAIL_USERNAME=user@******.**
MAIL_PASSWORD=*********
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="user@*****.**"
MAIL_FROM_NAME="${APP_NAME}"

但当我试图从我的应用程序发送电子邮件时,我会收到这个错误:

Failed to authenticate on SMTP server with username "user@*****.**" using the following
authenticators: "CRAM-MD5", "LOGIN", "PLAIN". Authenticator "CRAM-MD5" returned 
"Expected response code "235" but got code "535", with message "535 5.7.8 Error:
authentication failed: authentication failure".". Authenticator "LOGIN" returned 
"Expected response code "235" but got code "535", with message "535 5.7.8 Error: 
authentication failed: authentication failure".". Authenticator "PLAIN" returned 
"Expected response code "235" but got code "535", with message "535 5.7.8 Error: 
authentication failed: authentication failure".".

经过一些测试,我发现如果Password中有特殊字符,那么应该在.env文件中用双引号将其括起来。

最新更新