11305 Backup MX using sendmail - The FreeBSD Forums
The FreeBSD Forums  

Go Back   The FreeBSD Forums > Server & Networking > Web & Network Services

Web & Network Services Discussion related to network/web services such as apache, bind, sendmail, etc.

Reply
 
Thread Tools Display Modes
  #1  
Old August 7th, 2012, 19:43
matto25 matto25 is offline
Junior Member
 
Join Date: Mar 2011
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
Reply With Quote
  #2  
Old August 8th, 2012, 08:12
SirDice's Avatar
SirDice SirDice is offline
Moderator
 
Join Date: Nov 2008
Location: Rotterdam, Netherlands
Posts: 13,725
Thanks: 47
Thanked 2,023 Times in 1,862 Posts
Default

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.
__________________
Senior UNIX Engineer at Unix Support Nederland
Experience is something you don't get until just after you need it.
Reply With Quote
  #3  
Old August 8th, 2012, 13:12
kpa kpa is offline
Giant Locked
 
Join Date: Jul 2010
Location: People's Technocratic Republic of Finland
Posts: 2,015
Thanks: 44
Thanked 467 Times in 397 Posts
Default

Google is your friend:

http://www.itma.lu/howto/sendmail/secondary.htm
Reply With Quote
  #4  
Old August 8th, 2012, 14:15
matto25 matto25 is offline
Junior Member
 
Join Date: Mar 2011
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by SirDice View Post
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
Reply With Quote
  #5  
Old August 8th, 2012, 14:30
matto25 matto25 is offline
Junior Member
 
Join Date: Mar 2011
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by kpa View Post
Thanks for the link kpa,

other than the fact that the config files are different in that reference that's how I have setup the config on both primary and secondary servers "/etc/mail/relay.allow" is actually /etc/mail/access and DNS is setup correctly all IN A records not CNAMES.

Matt
Reply With Quote
  #6  
Old August 8th, 2012, 14:35
SirDice's Avatar
SirDice SirDice is offline
Moderator
 
Join Date: Nov 2008
Location: Rotterdam, Netherlands
Posts: 13,725
Thanks: 47
Thanked 2,023 Times in 1,862 Posts
Default

Quote:
Originally Posted by matto25 View Post
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
__________________
Senior UNIX Engineer at Unix Support Nederland
Experience is something you don't get until just after you need it.
Reply With Quote
  #7  
Old August 8th, 2012, 15:28
matto25 matto25 is offline
Junior Member
 
Join Date: Mar 2011
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by SirDice View Post
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?
Reply With Quote
  #8  
Old August 8th, 2012, 16:49
matto25 matto25 is offline
Junior Member
 
Join Date: Mar 2011
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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!!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
console log says: backup kernel: backup sendmail: fatal: usage: sendmail makdaddy8888 Web & Network Services 1 June 28th, 2012 05:27
cannot open /etc/mail/mailer.conf, using /usr/libexec/sendmail/sendmail as default MT sjap Web & Network Services 20 January 21st, 2012 15:16
Sendmail and Backup MX minimike Web & Network Services 1 September 25th, 2011 15:39
Using sendmail or sendmail from the ports? HL1234 Installation and Maintenance of FreeBSD Ports or Packages 3 December 17th, 2010 20:37
[Solved] zfs backup script for backup to disk jbeez General 3 September 10th, 2010 12:33


All times are GMT +1. The time now is 20:30.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
The mark FreeBSD is a registered trademark of The FreeBSD Foundation and is used by The FreeBSD Project with the permission of The FreeBSD Foundation.
Web protection and acceleration provided by CloudFlare
0