Ada*_*att 9 email sendmail office365 laravel
我想在 laravel 应用程序中使用我的 office365 smtp 凭据发送电子邮件。我在我的 .env 文件中对电子邮件设置进行了如下更改:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
MAIL_USERNAME=info@***.com
MAIL_PASSWORD=*******
MAIL_ENCRYPTION=tls
Run Code Online (Sandbox Code Playgroud)
当我尝试发送电子邮件时,我收到了类似的错误
Failed to authenticate on SMTP server with username \"info@omoyyc.com\" using 2 possible authenticators. Authenticator LOGIN returned Swift_TransportException: Expected response code 235 but got code \"535\", with message \"535 Incorrect authentication data\r\n\"
Run Code Online (Sandbox Code Playgroud)
我的电子邮件发送代码如下
Mail::send(array(), array(), function ($m) use ($templatecontent) {
$m->from('customerservice@****.com', 'TEST');
$m->to('test@gmail.com', 'Test')
->subject($templatecontent['subject'])
->setBody($templatecontent['content'], 'text/html');
});
Run Code Online (Sandbox Code Playgroud)
谁能指导我是什么问题以及如何解决这个问题?
小智 9
我遇到过同样的问题。我使用Gmail SMTP,启用了不太安全的应用程序并禁用了 2 因素身份验证,但没有任何效果。令人惊讶的是,正如 @jessij 提到的,将密码设置在双引号中是有效的。
在文件中执行以下操作.env:
Replace: MAIL_PASSWORD=yourpassword
With: MAIL_PASSWORD="yourpassword"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17002 次 |
| 最近记录: |