Search code examples
sendmailexim4

My web app server sends emails. I also use Google Apps to host my emails. I can't send messages to my own users?


Please excuse the horrible title. I've been banging my head against this issue all afternoon, only to realize that I was on a wild goose chase.

In short:

  • Set up Google Apps to handle incoming emails for my domain (foobar.org)
  • Set up exim4 on my Linode to send outgoing emails for my web app
  • Tested by sending emails to my private email ([email protected]), and to work email ([email protected]).

After 3 hours, I still could not figure out why emails were being received at otherdomain.net, but not at foobar.org.

So I gave up. Ctrl+D out of the super-user account, and saw: You have new mail in /var/mail/julian

facepalm


So, any outgoing emails sent to foobar.org get delivered to the local user account. Makes sense. How do I tell exim4 to send the email out to the interwebs, so when it comes back to my DNS, it'll be routed to Google's servers?


Solution

  • In the end, I had an incorrect hosts file entry added when setting up my server.

    I had the following entry:

    public-ip    domain.tld    machinename
    

    Although the following was more appropriate

    public-ip    machinename.domain.tld    machinename
    

    From then on, all emails sent to domain.tld ended up being sent out of the server.