The relay_based_on_MX feature is not needed.
1) Add an entry to your mailertable file:
mydomain.com esmtp:[ip of primary mail server]
2) Then add mydomain.com to /etc/mail/relay-domains.
Whatever you do... do NOT add mydomain.com to /etc/mail/local-host-names.
3) Rebuild the mailertable database and then restart sendmail
FWIW: There is a second option (this is what I do). Use the DSMTP mailer.
1) add mydomain.com to /etc/mail/mailertable:
mydomain.com dsmtp:[ip of primary mail server]
2) add my domain.com to /etc/mail/relay-domains.
3) Rebuild the mailertable database and then restart sendmail
makemap hash /etc/mail/mailertable.db < /etc/mail/mailertable
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
kill -HUP `head -1 /var/run/sendmail.pid`
The difference is now sendmail will queue all e-mail for mydomain.com
instead of trying to deliver to the primary (which is down). Plus the normal
sendmail queue runs will be ignored for e-mails that were queued with the
DSMTP mailer. i.e. No DSN's are issued should your primary be down for an
extended amount of time.
There is an added step to using the DSMTP mailer. To release the queued
e-mail from the backup server, you will need to issue an ETRN against the
backup mailer server from the primary when its backup and running. I simply
have a cronjob do this once an hour. Example:
Using the supplied etrn.pl script supplied with the sendmail source... from
the primary:
etrn.pl backup.mydomain.com mydomain.com
http://serverfault.com
We do exactly this.
You need to make entries in two configuration files.
First, enter the domains you are going to relay for in /etc/mail/relay-domains
, one per line. Include any variations.
Second, in /etc/mail/mailertable
, you have to tell sendmail what to do with mail destined for that domain.
Example:
/etc/mail/relay-domains
:
exampledomain.com
otherdomain.com
/etc/mail/mailertable
:
exampledomain.com relay:mailboxes.exampledomain.com
Remember to run make in /etc/mail
so that the changes to mailertable
take effect.
Note that if you don't put an entry in mailertable
for a domain, it will consult DNS and try to send to a 'better' MX; if DNS has nothing of use, it will try to deliver the mail locally (and fail, unless you've doctored/etc/mail/local-host-names
).
REFERENCES
http://www.mail-archive.com/redhat-list@redhat.com/msg116319.html
http://serverfault.com/questions/93977/configuring-sendmail-as-a-multi-domain-relay-server