tags:

views:

1240

answers:

9

I have a simple php script on my domain that sends me an email:

...
$toMail = "[email protected]"; //this works - I get the email at my gmail
$toMail = "[email protected]"; //this doesn't - I get nothing

mail($toMail, $subject, $message, $header);

What setting to I change to fix this?

A: 

make sure you can actually send mail to your domain email account and then check your code/email make sure everything is spelled right.. if none of this helped i dont know what went wrong..

techy
the email at my domain works. I can send and get email there using gmail or whatever. It just wont send with php. The spelling is fine. I've googled around and seen many have the same problem but no good explanation of a solution.
sol
+4  A: 

I had this problem myself, when i was redesigning a site recently. There was an issue with the way our system was setup so that they system thought that because the email was commign from the same domain it was a spam email and as such blocked it. Check with ya sys admin that you are allowed to be sending the emails etc. Either that or modify the headings to have it being sent from an external address. Hope you get it sorted.

schubySteve
A: 

Do you have your email hosted on a different server than the website? If that is the case the PHP script may be trying to send it internally in which case it'll just disappear, while the other target emails will get put on to the internet and routed properly.

The solution I found was to disable the mail server on your web host, and then PHP will put the message on to the internet to be sent properly.

Meep3D
No, it's the same server.
sol
A: 

Is this an existing mailing script, or are you just using the php mail function for it? If it is the latter issue, then the problem most likely has to do with the email's headers. Generally its not recommended to try and programmatically create an email yourself, I recommend checking this question on sending mail. For more information.

Noctrine
A: 

As explained by others, some servers are configured to reject emails missing a valid email address on the sending server. Check that the $headers string includes a defined valid email address "From:[email protected]".

Michelle
A: 

I had the same issue, and since I was hosted on another server for e-mail, I just had to disable the local mail server.

A: 

I had this problem a few times, and the culprit was if the email was being hosted on another server (e.g. Google Apps). When mail sends to the local domain, it doesn't bother doing a lookup on the MX record and therefore it will not get routed properly. The solution to this problem is just to simply have the mail function disabled on your server by your host.

A: 

I have the same problem! How do you disable the local mail server through htaccess?

SY
A: 

You need to set an additional parameter on your mail function. On your working example you would need to prepend your email address with '-f' e.g.

mail($toMail, $subject, $message, $header, "[email protected]");

David Pratt