Send email through Gmail SMTP to avoid local delivery attempts?

feklee asked:


We use Google Apps for email with our domain

[[email protected] ~]$ dig MX
;; ANSWER SECTION:            300     IN      MX      1            300     IN      MX      5            300     IN      MX      5            300     IN      MX      10            300     IN      MX      10

On the same domain we have an EC2 instance running, with Amazon Linux AMI
(Centos based). sendmail works fine for addresses. However,
for, it tries to deliver mails locally, which fails for
users that exist only on Google Apps. Interestingly this is despite
local-host-names being empty.


To avoid local delivery attempts, can we set up sendmail so that it sends all email
through Google’s SMTP server (requires authentication)? Would that be a good idea? Or is
there a better solution?

Additional information

  • Also, it would be interesting to configure the server to send email to
    local addresses root and ec2-user to the Google Apps user
    [email protected]. I guess, we would use mail aliases for that.

  • FQDN:

    [[email protected] ~]$ hostname --fqdn

    Of course, the actual server name is not It’s another .com domain.

  • As requested by @AndrzejA.Filip:

    [[email protected] ~]$ echo '$j' | sendmail -bt
    ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
    Enter <ruleset> <address>
    > [[email protected] ~]$

My answer:

You named your server, the naked domain name. Thus many programs (sendmail included) take you at your word, and consider that the local server does everything related to that domain name.

To resolve the problem, rename the host. For this and a variety of other reasons, no server should ever be named with only its naked domain name.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.