I just need a really simple email to be sent when a user submits a form on my website. (I've looked into using PHPMailer, but have failed to have it actually send an email. I've kind of given up on it because it really is more complex than I need.) In my form handling .php file, I have this code at the end:
if (!mail($_POST['email'], "Registration - Your New Password", "Your password is: ".$pass))
echo "didn't send email";
else echo "email sent";
I get a message saying "email sent," but I never receive any emails when I put in my personal email address. Does anyone know why this code seems to be interpreted correctly but yet it doesn't send emails?
Here are some steps I took before testing the above mail():
1) I installed ssmtp
2) I configured /etc/ssmtp/ssmtp.conf so that it looks like this:
root=postmaster
root=myemail@gmail.com
mailhub=smtp.gmail.com:587
UseSTARTTLS=YES
AuthUser=myemail
AuthPass=mypass
hostname=mywebsite.com
FromLineOverride=NO
3) In /etc/php5/apache2/php.ini
and in /etc/php5/cli/php.ini
I set the line starting sendmail_path
to sendmail_path = /usr/sbin/ssmtp -t
4) I've restarted apache2: "sudo service apache2 restart"
Note: I've seen lots of other posts on this topic on SO, but haven't really found any solutions in those questions. Perhaps I missed the solution in these other posts, so if that's a case, could you give me the link to that other post?