Search the Community
Showing results for tags 'fail'.
-
Is there any restriction on sending e-mails using mail() to the same domain that is hosting the script? I'm slowly building my site during my free time and just noticed that my contact form isn't working properly. It spits out no error, but the mail never reaches it's destination. So, I've created the following test file (let's say my domain is "example.com"): <?php error_reporting(E_ALL); $to = "me@example.com"; $subject = "Test Mail"; $message = "Hello world!"; $headers = "From: no-reply@example.com"; echo mail($to, $subject, $message, $headers) ? "The email was sent" : "Fail!"; ?> Playing with this file I discovered that my mail never gets sent only if the recipient I've specified is from my own domain, the same domain which is hosting the script. If I change it to another one (gmail in this case) it works without problems: <?php error_reporting(E_ALL); $to = "me@gmail.com"; $subject = "Test Mail"; $message = "Hello world!"; $headers = "From: no-reply@example.com"; echo mail($to, $subject, $message, $headers) ? "The email was sent" : "Fail!"; ?> What really puzzles me is that this code works flawlessly in another host - and yes, using my domain. I've been using an DNS Round Robin to check out it's pros & cons and I'm able to test both hosts at the same time. Some useful (or not) information: My MX records are pointing directly to Google's records, since I'm using their Tools, and I'm also using an spf. I'm not using any nameservers, but A records only. The round robin has been working like a charm so far and the only problem I've encountered is the mail() one. I don't see how the round robin could have anything to do with this. If you need more info like seeing my DNS records, or how my mail headers looks like when I manage to send them (through the other host/to my gmail account) just ask. P.s.: English isn't my mother tongue, sorry about any weird sounding sentence. Also, I wasn't sure about where post it. Since it looks like a host-restriction, I've chosen this section.