laravel SMTP邮件

I am trying to send the mail using smpt on google mail my .env file is

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=MYEmailAddress
MAIL_PASSWORD=MyPassword
MAIL_ENCRYPTION=tls

and the server code is

try {
        Mail::send([], [], function ($message) use ($completeView,$emailAdress) {
            $message->to($emailAdress, $emailAdress)->subject("Property List");
            $message->from("Myemail", "info")->setBody($completeView, 'text/html');
        });
    } catch (\Exception $e) {
        return array([$e->getMessage(),"Myemail"]);
    }

I also enable the Less secure app access in gmail and the response I get from the server is

Expected response code 250 but got code \"530\", with message \"530 5.7.1 Authentication required

duanmiaosi0150
duanmiaosi0150 请通过编辑问题将有关响应代码的信息放入问题本身。
11 个月之前 回复
dongmou5628
dongmou5628 仍然得到错误预期的响应代码250,但得到代码“530”,消息\“5305.7.1认证需要
11 个月之前 回复

1个回答

  1. if you are using gmail address to sent mail. then you need to on less secure app.

    go to https://myaccount.google.com/lesssecureapps

    then allow by turning it on.

    and also use php artisan config:clear

  2. sometimes google blocks when you try to send email through some code. In that case you got a alert mail. click on that mail(Check Activity) and mark as yes (Do you recognize this activity?)

  3. Or you can try MAIL_DRIVER=sendmail and also use php artisan config:clear

展开翻译

译文




  1. 如果您使用gmail地址发送邮件。 然后你需要安装不太安全的应用程序。</ p>

    转到 https:// myaccount.google.com/lesssecureapps </ p>

    然后启用它。</ p>

    并使用php artisan config:clear </ p> </ li>

  2. 当您尝试通过某些代码发送电子邮件时,有时会阻止Google阻止。 在那种情况下,你有一个警报邮件。 单击该邮件(检查活动)并标记为是(您是否认可此活动?)</ p> </ li>

  3. 或者您可以尝试MAIL_DRIVER = sendmail并使用php artisan配置: 清除</ p> </ li>
    </ ol>
    </ div>

duadlkc5762218
duadlkc5762218 修复了这个问题。 我正在推送.env文件但是没有更新购买laravel forge。 Manullay更新.env文件。 现在邮件正在运行
11 个月之前 回复
douzheng1853
douzheng1853 我尝试使用双向身份验证创建一个名为Laravel的应用程序然后生成密钥MAIL_DRIVER = smtp MAIL_HOST = smtp.gmail.com MAIL_PORT = 587 MAIL_USERNAME = MYEmailAddress MAIL_PASSWORD = generatedPassword MAIL_ENCRYPTION = tls仍然得到相同的响应预期的响应代码250但是得到了 代码“530”,带消息\“530 5.7.1需要验证还要在部署脚本中添加php artisan config:clear
11 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问