Email not Sending to Same Domain?

May 8th, 2009
5 comments Email posted by Pete

Have you ever run into the problem where you are setting up a contact form, or something similar, and then having the contact form email you at an email address that’s on the same domain, and then** you mysteriously don’t get the email?

For example:
My contact form is at:

http://www.mysite.com/contact/

The email address my form sends to using PHP’s mail() function is:
me@mysite.com

Ok so, looking good yeah? But I don’t get the email. So I switch where the email is going to a placebo account, say “me@gmail.com” — And then I GET the email. So the form obviously works, but there’s a disconnect happening somewhere.

What I’ve discovered is that this problem most likely occurs if you are pointing your MX Records and A Records to different places. I, for example, am using a 3rd party hosting company to physically host this website, but I’m using Gmail to handle my email.

What happens is your server most likely has a firewall setup so that any email coming through from your domain to an email on your domain is filtered. IE, your server looks it up and says “Hmmm… there isn’t an email setup by any name that this form is trying to send to. I will henceforth banish thee to oblivion.” And then it casts a magic spell it learned from Gromak the Incorrigible, and then (HAH! had to) your email simply dissolves peacefully, or so we can hope, into the ethereal where it will exist in limbo, haunting you for the rest of your days. Most likely.

The Fix:
Basically you have to configure your server so IT knows (not just the rest of the free world) that you are using an outside service to handle your mail.

In Cpanel:

  1. Click MX Entry
  2. In the table, find the domain your trying to configure and click it under the “MX Entry” column. This should allow you to edit it.*
  3. Change it to the MX Record of your mail provider. For example, I use Gmail, so I set it to ASPMX.L.GOOGLE.COM
  4. Press “Change” and voila. Many Roman women will abruptly appear, draping themselves over your suddenly bulging, muscular body as you bath in the glory of your fastidious conquest. Or you’ll just be able to send mail from your form. Either way: Awesomeness ensues.

Now, granted, these are just the instructions for CPanel, but it should work regardless of your system setup, the steps just may be a little different. The idea here is that you want to tell your server that you aren’t using them for mail, essentially updating the SMTP Localhosts records so they know which to use.

Happy days.


* It should probably be set the same as your domain. This is whats causing the problem
** I’m trying to break the record for as many “and then”’s in one sentence as possible **fingers crossed!**

  1. cPanel Host said on 06/20/10

    Great post. Stumbled!

  2. T Rider said on 02/24/11

    This was the most concise and correct answer to this problem. Many face this problem and your answer fixed it in 2 minutes. Many thanks for putting this up.

  3. mx record lookup said on 06/03/11

    many thanks for providing this information. thanks

  4. Samual Saintamand said on 07/20/11

    Thanks a bunch for this tip.

  5. Laura Brisbane said on 08/16/11

    Greetings from Sydney. Thanks for the useful data. I’m doing a project at uni and your stuff was quite useful. Thanks for sharing :)

Leave a Reply