Swiftmailer config : send mail using gmail

放肆的年华 提交于 2019-12-04 16:42:19
Filippos Karapetis

Looks like your live server is missing OpenSSL, so you need to enable it in order to get secure connections working (i.e. enable the php_openssl module). Also check this question.

After some search in google.

To send mail using gmail auth you need to use this code,

$transport = Swift_SmtpTransport::newInstance('ssl://smtp.gmail.com', 465);

This is the correct way to send mail. This mail will be send by gmail.


PHP use mail() to send just a mail,

mail($to,$subject,$message,$headers);

This code sends a mail using php code.

Swiftmailer can also send a mail using this php mail() function,

Here is swift code.

$transport = Swift_MailTransport::newInstance();
// nothing inside ()

The problem in this mail is, gmail displays following message,

This message may not have been sent by: username@gmail.com

Sometimes this mail will go to spam.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!