Disable local delivery in Sendmail
Solution 1:
What I did to disable local delivery. I'll be using the example.com domain.
Requirements:
- example.com A entry pointing to IP address assigned to one of the eth interfaces.
- /etc/hosts defining example.com assigned to the very same IP address as above
- example.com MX records pointing to Google servers (ASPMX.L.GOOGLE.COM, etc)
- default sendmail installation (mine was on Ubuntu)
Steps:
vim /etc/mail/sendmail.mc
at the end:
define(`MAIL_HUB', `example.com.')dnl
define(`LOCAL_RELAY', `example.com.')dnl
and then:
sendmailconfig (or /etc/mail/make depending on your distro)
service sendmail restart
testing:
echo -e "To: [email protected]\nSubject: Test\nTest\n" | sendmail -bm -t -v
echo -e "To: user\nSubject: Test\nTest\n" | sendmail -bm -t -v
You should see it connecting to the google server and then you should see your mail being delivered to your Google inbox.
Solution 2:
Thanks to sporker and Pawel you put me in the right direction to get this fixed.
My original problem was that sendmail was considering my domain example.com email accounts as local accounts.
These links proved very useful: Sendmail to local domain ignoring MX records (part 2) http://lists.freebsd.org/pipermail/freebsd-questions/2004-September/057382.html http://objectmix.com/sendmail/367920-sendmail-ignores-mailertable-some-semilocal-domains.html
But in my case, using FreeBSD 8.2, what really did the trick was:
# cd /etc/mail
# vim freebsd.mc
Add these two lines:
define(`MAIL_HUB', `example.com.')dnl
define(`LOCAL_RELAY', `example.com.')dnl
Right before:
MAILER(local)
MAILER(smtp)
# make
--- This is output ---
cp freebsd.mc host.example.com.mc
/usr/bin/m4 -D_CF_DIR_=/usr/share/sendmail/cf/ /usr/share/sendmail/cf/m4/cf.m4 host.example.com.mc > host.example.com.cf
cp freebsd.submit.mc host.example.com.submit.mc
/usr/bin/m4 -D_CF_DIR_=/usr/share/sendmail/cf/ /usr/share/sendmail/cf/m4/cf.m4 host.example.com.submit.mc > host.example.com.submit.cf
--- End of output ---
# cp sendmail.cf sendmail.cf.bak
# cp host.example.com.cf sendmail.cf
# /etc/rc.d/sendmail restart
Hope this saves some headaches to someone.