How can I use my GMAIL account to send out emails using PHP?

怎甘沉沦 提交于 2019-12-10 12:26:27

问题


After searching for days on how to do this I came across this question: Send email using the GMail SMTP server from a PHP page

Seems like exactly what I have been trying to achieve but I have had no success, maybe it's because I don't know how to do the HTML to work with this code?

for testing purposes I tried the code on the top voted question on the link I pasted and made a button that when you click it, it would go to the PHP file (No success).


回答1:


You can't do it with PHP only, because mail() doesn't support authentication. You have to use a mailing library.
I recommend SwiftMailer which is easy to use, supports many features (authentication, sending HTML mails, attachments, etc.), and is well documented.




回答2:


You also need to send over tsl/ssl which is why your mail function is not working.

Solution with tsl/ssl already exists here: Using php's swiftmailer with gmail




回答3:


Check http://neo22s.com/send-email-using-gmail-and-php/ and http://webcodingeasy.com/PHP-API039s/Send-email-from-Gmail-using-PHP



来源:https://stackoverflow.com/questions/10635432/how-can-i-use-my-gmail-account-to-send-out-emails-using-php

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