Laravel 无法发送邮件原因

"message": "Connection could not be established with host smtp.qq.com :stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known",
"exception": "Swift_TransportException",
"file": "/www/wwwroot/haotuce.com/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php",
"line": 261,

解决方法:

修改项目中 config/mail.php 文件

‘mailers’ => [
‘smtp’ => [
‘transport’ => ‘smtp’,
‘host’ => env(‘MAIL_HOST’, ‘smtp.mailgun.org’),
‘port’ => env(‘MAIL_PORT’, 587),
‘encryption’ => env(‘MAIL_ENCRYPTION’, ‘tls’),
‘username’ => env(‘MAIL_USERNAME’),
‘password’ => env(‘MAIL_PASSWORD’),
‘timeout’ => null,
‘auth_mode’ => null,
‘stream’ => [
‘ssl’ => [
‘verify_peer’ => false
],
],
],],

 


参考:

https://learnku.com/articles/24554?spm=a2c6h.13066369.0.0.494c77a79ehiui