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 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 ubuntu系统下挂载磁盘上执行./提示权限不够
  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误