Backup MX using sendmail

Sorry if this has been posted before but I couldn't search out what I was trying to do so here it is..

I have several domains on several different boxes which I would like to have the mail backed up in the event that the primary mail server goes down. I do NOT want a secondary mail server with replicated accounts or anything like that just a second server that catches and queues up the mail until the primary is responsive again, this is how I have configured it and the problem I am having.

DNS for the primary

0 mail.mydomain.com
5 mail2.mydomain.com
10 mail3.mydomain.com

Config on mail2.mydomain.com

In /etc/mail/access I have added
Code:
To:mydomain.com                      RELAY
I'm clearly missing something here but have yet to find anything that works online. When I kill sendmail on the primary server and attempt to send an email to the domain I see the mail come into the secondary back server when doing a tail -f on the maillog after the two lines of the email coming in I get a 3rd line stating
Code:
(SYSERR(root): mail2.domain.com. config error: mail loops back to me (MX problem?)
Now that being said I understand why it's saying this but (haha why is it doing this??) it seems to instantly try and relay the mail to the primary over and over again 25 times then fails sending a bounce back
Code:
A configuration error in the e-mail system caused the message to bounce between two servers or to be forwarded between two recipients.  Contact your administrator.
<ns2.server.com #5.4.6 SMTP; 554 5.4.6 Too many hops>
I am clearly missing a configuration or something but can't seem to figure it out,

Thanks Guys!

Matt
 
You're relaying to the domain. Sendmail will look up the MX record for that domain, it'll find your primary is down and switch to the secondary MX record. Which is the same server that's trying to send the mail. Hence the loop-back NDR.

Relay to the specific hostname or IP address of the primary. It shouldn't be able to deliver it when it's down and will then start queuing it.
 
SirDice said:
You're relaying to the domain. Sendmail will look up the MX record for that domain, it'll find your primary is down and switch to the secondary MX record. Which is the same server that's trying to send the mail. Hence the loop-back NDR.

Relay to the specific hostname or IP address of the primary. It shouldn't be able to deliver it when it's down and will then start queuing it.

Thanks for the reply SirDice,

I don't quite understands what you are telling me to do here. Where do I add the IP or hostname, in what config file?

Thanks

Matt
 
matto25 said:
I don't quite understands what you are telling me to do here. Where do I add the IP or hostname, in what config file?
This:
Code:
To:mydomain.com                      RELAY
Tells sendmail to relay to the domain. Sendmail will lookup the MX records for that domain and use those to send the mail to. Because your primary MX is down it will automatically use the secondary MX record. Which points back to itself. Keep in mind that your mailserver has no concept of primary and secondary, it simply accepts mail and tries to forward it to wherever you tell it to.

Change it to:
Code:
To:hostname.of.primary.mail.server   RELAY
Or, to the IP address of the primary mail server
Code:
To:1.2.3.4                      RELAY
 
SirDice said:
This:
Code:
To:mydomain.com                      RELAY
Tells sendmail to relay to the domain. Sendmail will lookup the MX records for that domain and use those to send the mail to. Because your primary MX is down it will automatically use the secondary MX record. Which points back to itself. Keep in mind that your mailserver has no concept of primary and secondary, it simply accepts mail and tries to forward it to wherever you tell it to.

Change it to:
Code:
To:hostname.of.primary.mail.server   RELAY
Or, to the IP address of the primary mail server
Code:
To:1.2.3.4                      RELAY

I see what you are saying here and that's what I thought you meant BUT if I do that I get relaying errors if by IP or hostname of the primary so this doesn't fix the problem it creates a different error saying relaying denied.. For sure this is something stupid that I am missing. Any other ideas?
 
I found the missing link! domain.com smtp:mail.domain.com had to be added to /etc/mail/mailertable rebuilt the databases restarted sendmail, killed sendmail on the primary and sent a test and no more bounce backs and the mail is queueing now thanks for your help!!
 
Back
Top