doutang1884 2016-06-27 14:58
浏览 66
已采纳

Laravel发送电子邮件,配置和发送脚本

I have a problem with my laravel email client. I need to send email by click button.

my code: .env

MAIL_DRIVER=smtp
MAIL_HOST=mail.somedomain.com
MAIL_PORT=587
MAIL_USERNAME=test@somedomain.com
MAIL_PASSWORD=123456
MAIL_ENCRYPTION=null

I think it is good configuration, of course i'm using my domain :)

next in controller I have code like this:

Mail::send('home', array('firstname' => "fname"), function($message){
$message->to("testsend@somedomain.com")->subject('Welcome to the Laravel');
});

Website is open normally but email not send

  • 写回答

1条回答 默认 最新

  • dongzhijing8202 2016-07-04 11:59
    关注

    In Gmail account

    My account > Sign In And Security > Sign In to google, enable two step verification

    Create One App and generate password

    In your .env file

    MAIL_DRIVER=smtp
    MAIL_HOST=smtp.gmail.com
    MAIL_PORT=587
    MAIL_USERNAME=myemail@gmail.com
    MAIL_PASSWORD=apppassword // this is created from gmail app password
    MAIL_ENCRYPTION=tls
    

    And Then run php artisan config:cache

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

报告相同问题?

悬赏问题

  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64
  • ¥15 iOS 自定义输入法-第三方输入法