tags:

views:

52

answers:

3
A: 

Assuming that sendmail is working on your system, and that PHP is configured to use it correctly, try adding -f in the additional parameters, like this...

mail($EMAIL, $subject, $message, '[email protected]'

This sets the envelope with a proper from address. See more on the PHP site: http://www.php.net/manual/en/function.mail.php#92528

Brad
+1 for the `-f`, but you'd want to include the normal additional headers 4th parameter first to include the normal `From: ` address.
philfreo
+1  A: 

There a lot of possible reason that could explain why your email is sent and not received. Beside just setting up your SMTP server there are other things you need to do to make sure your email isn't just dropped before it reaches his destination.

You should take a look at this article that explains, what you should check :

http://www.codinghorror.com/blog/2010/04/so-youd-like-to-send-some-email-through-code.html

In summary you need to :

HoLyVieR
A: 

Check your mail log (usually /var/log/maillog). It would show the message arriving from PHP, and any delivery attempts/rejection notices from the MX of the receiver.

Marc B
I have done this, at first it said there was an error as there was no sender, now it says status=deferred (delivery temporarily suspended: connect to alt4.gmail-smtp-in.l.google.com[74.125.67.27]:25: Connection timed out)
Temporarily suspended is either due to throttling, or google's using grey listing and expecting your server to retry again later. That means your code's working fine and PHP is delivery the mail properly, but something's acting to trigger anti-spam measures.
Marc B