我在使用gmail通过Laravel 5.1应用程序发送电子邮件时遇到了麻烦。
这是我的配置文件:
<?php
return [
'driver' => 'sendmail',
'host' => 'smtp.gmail.com',
'port' => 578,
'from' => array('address' => 'adresse@gmail.com', 'name' => 'Something'),
'encryption' => 'tls',
'username' => 'someaddress@gmail.com',
'password' => '****',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
];
启用了安全性较低的应用以访问您的帐户。
我应该使用什么配置?
答案 0 :(得分:2)
另外,设置.env
如下
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=something@gmail.com
MAIL_PASSWORD=*********
MAIL_ENCRYPTION=tls
并设置config/mail.php
如下
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => 'something@gmail.com',
'name' => env('MAIL_FROM_NAME', 'Admin'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME','something@gmail.com'),
'password' => env('MAIL_PASSWORD','*********'),
'sendmail' => '/usr/sbin/sendmail -bs',
希望有帮助!