I had problems with mail delivery on one server where server self doesn’t have any email services. The case was following: server’s hostname was example.com and emails for example.com was handled by another server. By default sendmail will treat all emails sent to example.com meant for local users eg. user@example.com will be searched from local user table.
I wanted all emails to example.com to be delivered to domains email server which was defined on MX record. I’m not sendmail expert and for my own servers I prefer postfix, but this was client’s server so I had to figure out how to configure sendmail handle this case.
Solution is quite simple and straightforward but needed little time for googling and that is the reason for this short blog post. This same time reference for myself :) Only thing I had to do was add following line end of file /etc/mail/sendmail.mc
define(`LOCAL_RELAY', `example.com.')dnl
After that I had to generate configuration file from that macro file:
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
This command needs package sendmail-cf to be installed on server. Last step was to restart sendmail and voila! Now email to user@example.com will be delivered to real email server.

Comments