问题
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