duanqiao1926 2019-03-03 10:30
浏览 234
已采纳

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

  • 写回答

1条回答

  • douzhang5984 2019-03-03 10:44
    关注
    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常
  • ¥15 关于风控系统,如何去选择
  • ¥15 这款软件是什么?需要能满足我的需求
  • ¥15 SpringSecurityOauth2登陆前后request不一致