[英]Send Laravel 5.5 mail using gmail
I have been getting an error while i try to send an email using laravel 5.5 with gmail. 我尝试使用laravel 5.5和gmail发送电子邮件时遇到错误。
MAIL_DRIVER=smtp
MAIL_HOST=gmail-smtp-msa.l.google.com
MAIL_PORT=587
MAIL_USERNAME=mygmailadress
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=tls
I changed the mail host from smtp.google.com to that one becuase i could not reach smtp.google.com 我将邮件主机从smtp.google.com更改为那个,因为我无法访问smtp.google.com
Here is the error i get when i try to send mail 这是我尝试发送邮件时遇到的错误
stream_socket_enable_crypto(): Peer certificate CN=`smtp.gmail.com' did not match expected CN=`gmail-smtp-msa.l.google.com'
And this is the error that i use when i use mail_host smtp.google.com 这是我使用mail_host smtp.google.com时使用的错误
Connection could not be established with host smtp.google.com
[php_network_getaddresses: getaddrinfo failed: Name or service not known #0
Note that everything was working well with my testing server mailtrap. 请注意,我的测试服务器邮件陷阱一切正常。 So how can i make this work for production?
那么我怎样才能使这项工作投入生产呢?
you have error in mail host MAIL_HOST=smtp.gmail.com
您在邮件主机
MAIL_HOST=smtp.gmail.com
有错误
As per your question you have used MAIL_HOST=gmail-smtp-msa.l.google.com
and MAIL_HOST=gmail-smtp-msa.l.google.com
根据您的问题,您已使用
MAIL_HOST=gmail-smtp-msa.l.google.com
和MAIL_HOST=gmail-smtp-msa.l.google.com
But gmail host is smtp.gmail.com
但是gmail主机是
smtp.gmail.com
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=mygmailadress
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=tls
Usually setting encryption to ssl works: 通常将加密设置为ssl可以工作:
'encryption' => 'ssl'
On your config/mail.php
: 在您的
config/mail.php
:
But you better try to stick with smtp.gmail.com
: 但是您最好尝试坚持使用
smtp.gmail.com
:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=mygmailadress
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=ssl
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.