Im trying to send a simple mail on my local machine to my gmail account. Mail() always returns TRUE but never send anything.
This is the simple PHP code i'm running
$header = "From: xyz@gmail.com\r\n";
$header.= "MIME-Version: 1.0\r\n";
$header.= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$header.= "X-Priority: 1\r\n";
if(mail("zyx@gmail.com", "This some subject", "This is some message body",$header))
echo "Sent";
else
echo "Not sent";
I'm now using postfix (before it was sendmail).
This is /var/log/mail.log
Dec 30 09:50:14 localhost postfix/pickup[7452]: BB3E3861B90: uid=33 from = www-data
Dec 30 09:50:14 localhost postfix/cleanup[7677]: BB3E3861B90: message-id=<20151230142014.BB3E3861B90@daniel-Inspiron-N4050>
Dec 30 09:50:14 localhost postfix/qmgr[1542]: BB3E3861B90: from=, size=476, nrcpt=1 (queue active)
Dec 30 09:50:14 localhost postfix/error[7679]: BB3E3861B90: to=, relay=none, delay=0.28, delays=0.16/0/0/0.12, dsn=5.0.0, status=bounced (citr$
Dec 30 09:50:14 localhost postfix/cleanup[7677]: EC875861B91: message-id=<20151230142014.EC875861B91@daniel-Inspiron-N4050>
Dec 30 09:50:15 localhost postfix/bounce[7680]: BB3E3861B90: sender non-delivery notification: EC875861B91
Dec 30 09:50:15 localhost postfix/qmgr[1542]: EC875861B91: from=<>, size=2279, nrcpt=1 (queue active)
Dec 30 09:50:15 localhost postfix/qmgr[1542]: BB3E3861B90: removed
Dec 30 09:50:15 localhost postfix/local[7683]: EC875861B91: to=, relay=local, delay=0.15, delays=0.07/0/0/0.08, dsn=2.0.0, status=sent ($
Dec 30 09:50:15 localhost postfix/qmgr[1542]: EC875861B91: removed
I also check and there's not mail queue.
I have also tried all solutions exposed here PHP mail form doesn't complete sending e-mail
- Make sure actually call the mail() function
- Check server's mail logs
- Don't use the error suppression operator
- Check to see if mail() returns true or false: returns true
- Check spam folders / Prevent your email from being flagged as spam
- Make sure supply mail headers
- Make sure mail headers do not have a syntax error
- Make sure recipient value is correct: are my personal emails
- Send to multiple accounts
- If on localhost, make sure you have a mail server set up
Thanks!