Google Hosted Apps and Sending Mail From a Web Server

Recently, I discovered that while hosting your e-mail services on Google has its advantages, it also brings with it some minor inconveniences. When you use a script on most Web servers to send e-mail messages, if your e-mail is not hosted locally on that server, your e-mail messages will never arrive in your inbox. Instead, the mail gets delivered to an e-mail account on your Web server if there is one; if there isn’t, the message gets rejected and goes into a black hole.

Basically, what happens is, if your domain name is associated with a Web server, any e-mail messages sent from that server will be processed directly by the mail application on that Web server, rather than going out to various name servers to look for the appropriate destination.

This issue can be fixed. Apparently, there are two files (on a LAMP server, at least) that designate whether e-mail should be processed locally or go out and search for nameservers. They are /etc/localdomains and /etc/remotedomains. In most cases, by default, your domain name will be found within /etc/localdomains. Any time an e-mail message is dispatched by a Web server, those two files are searched. If the domain name associated with the destination e-mail address is found within localdomains, the message is processed locally. If it’s found within remotedomains or isn’t found at all, the server looks for name servers to tell it where the e-mail message needs to go.

Therefore, if your e-mail is not hosted on your Web server, you may need to request that your host update the /etc/localdomains and /etc/remotedomains files appropriately. In some cases, there are multiple copies of these files, all of which need to be updated accordingly.

So, if you have a script installed on your Web server that’s supposed to send e-mail messages to you, and you find that you’re not receiving any of those messages in your remotely-hosted e-mail account (Google Apps, for instance), you may be experiencing the issue discussed in this post. If that’s the case, with most Web hosts, you can simply notify them of the issue and ask them to correct it.