mattgadient.com

Fixing a broken contact form on a Joomla site

Recently, I switched most of my sites to another server.

After about a week of not receiving any messages through the contact form on one of them, I suddenly realized… “ya know… it’s been a while”. I tried sending myself a test message through the contact form, and never received it. Sending from another email account worked though. Strange…..

Before going any further it’s worth noting that I’m using Google Apps on the aforementioned site for mail (gmail for domains).

To narrow down the cause, I did a couple things. First, I came across a little script on the Joomla forums (thanks to “ChiefGoFor”). It basically tests the PHP mail function (which Joomla uses by default) and looks like this:

<?php
mail(“youremail@domain.com”, “Testing PHP mail”, “Email sent successfully”);
echo “script complete.”;
?>

I made a file called “testmail.php”, plunked that code in, changed the email address to a hotmail one that I own, and opened in in my web browser. It worked.

——

Next I tried changing the email address it sends to from within the Joomla site, again, pointing it to the hotmail one I tried above.

It worked!

Problem was obviously either Google not accepting messages from the server, or the server not sending to Google for some reason.

I popped open WHM, and ran the “Mail Troubleshooter” (under the “Email” section in WHM). When I typed in the address hosted through Google Apps, it spit out the following message:

virtual_aliases via virtual_aliases router forced address failure

Fun.

I tried entering a hotmail address, and it showed the proper MX lookups through Hotmail.

Now all the pieces were falling together.

Here’s what was happening….

  • The DNS isn’t hosted on the web server in my case. It’s hosted elsewhere. It’s properly set up (MX records and all).
  • The web server however doesn’t look at the DNS server for a site contained on the web server. After all, why would it spend the time to look itself up?
  • In short, while MX records were properly set up on the DNS server, they also have to be set up on the web server if it ever sends mail to an email address that reflects a domain on the server which is hosted elsewhere.

I’ll draw a little picture to explain it a little better.

web-server-dns-email-process-google-apps

As you can see from my wonderful drawing, if your mail is hosted somewhere else, it won’t matter that your separately-hosted DNS server was set up correctly – you’ll still have to add the MX entries to the web server (otherwise it’ll just look at itself).

The good news is that for those who self-host their DNS, WHM/CPanel will pick up the MX entries when you add them to the zone file.

For everyone else, MX entries can be added easily in CPanel’s “MX Entry” section.

 

  • Brilliant. Great bit of diagnostics, and from my perspective, fantastic that you shared it with everyone.

    Solved the problem that I’ve had for the past 12 hours.

    Thanks so much

    Dave

  • brad

    thanks alot, i had the same problem, pictured cleared it up and i got it working

  • Thanks a lot Matt!
    You explained it really well.. and the drawing is simple and to the point.. no fancy extras.. [i am a designer 🙂 ]

    Had the same issue with one of my websites and adding the MX records solved the problem.

  • Pichetou

    I’m facing the same problem here, but I can’t figure out what the MX entries that I have to add should look like. I have these now (which Google filled itself, I’m using GoDaddy):

    Priority__Host___Points to___________________TTL

    20_____@______ALT1.ASPMX.L.GOOGLE.COM___1 Hour

    30_____@______ALT2.ASPMX.L.GOOGLE.COM___1 Hour

    10_____@______ASPMX.L.GOOGLE.COM_______1 Hour

    40_____@______ASPMX2.GOOGLEMAIL.COM____1 Hour

    50_____@______ASPMX3.GOOGLEMAIL.COM____1 Hour

    What should I add? Thanks a lot

    • Pichetou: Those look correct. Depending on the webhost interface you’re using, it’s possible that you might have to add an extra period after each item so that they look like: ALT1.ASPMX.L.GOOGLE.COM. (final period after .COM).

      To verify that it works, if you’re comfortable with SSH and have access through your host, typing something like the following in the shell will often let you know if your settings are working:
      echo "hello" | mail -vv name@website.com

      You should see in the output whether it’s correctly attempting to access Google’s mail servers and is successfully being accepted. Note that sometimes the mail will go to a spam folder or be rejected by Google’s mail servers if you haven’t set up appropriate TXT/SPF records for the DNS to whitelist the server your website is on.

      Good luck!