MAIL_DRIVER=sendmail
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=password
MAIL_ENCRYPTION=ssl
我尝试了ssl和tls与他们各自的代码,但显示Swift_TransportException连接无法与主机smtp.gmail.com建立[连接超时#110]
Mail::send('email.contact', $data, function($message) use ($data){
$message->from($data['email']);
$message->to('[email protected]', 'Admin');
});
一般不建议gmail在实时服务器上发送电子邮件,但如果您只是将其用于测试目的,请确保您在less secure app
下允许https://myaccount.google.com/security为YES并允许在https://accounts.google.com/b/0/DisplayUnlockCaptcha上使用验证码。
执行上述操作后,只需清除缓存,电子邮件就可以正常运行。
您尝试使用带有SMTP的465端口,这很好,但可以尝试使用587端口。