Sendmail and backup MX

John Rudd jrudd at UCSC.EDU
Mon Sep 26 22:37:04 IST 2005


On Sep 26, 2005, at 12:13, Scott Silva wrote:

> Not a MailScanner issue, but ...
> Does anybody have any simple solutions for sendmail that only lets the
> backup MX accept mail when the primary is down?
> I don't want to re-invent the wheel if someone already has a working
> solution.
>

Get mimedefang.  Run it on your backup.  www.mimedefang.org


There's a function it has called "filter_recipient" which you have to 
write (in /etc/mail/mimedefang-filter), and which you have to turn on 
in the startup script.  Here's what I would suggest:


sub filter_recipient {
    my ($recip, $sender, $ip, $host, $first, $helo, $rcpt_mailer,
        $rcpt_host, $rcpt_addr) = @_;
    my ($type, $msg);

    # if the recipient is in the domain I secondary
    if ($recip =~ /\@primary\.domain\.name\b/i) {

       # verify a known recipient on the primary
       ($type, $msg) = md_check_against_smtp_server($sender,
                         $recip,                # known recipient
                         "secondary.host.name", # your backup/MX server
                         "primary.host.name");  # the primary mail server

       if ($type  eq "REJECT") {
          # the recipient doesn't exist, hard reject even if
          # the primary is up
          return ('REJECT', "Unknown Recipient");
          }
       elsif ($type eq "CONTINUE") {
          # if you can verify it, then the primary is up
          # TEMPFAIL (or REJECT) the message
          return ('TEMPFAIL', "Only call me when the primary is down");
          }
       else {
          # else, primary is down or having problems
          return ('CONTINUE', "OK");
          }
       }
    }

------------------------ MailScanner list ------------------------
To unsubscribe, email jiscmail at jiscmail.ac.uk with the words:
'leave mailscanner' in the body of the email.
Before posting, read the Wiki (http://wiki.mailscanner.info/) and
the archives (http://www.jiscmail.ac.uk/lists/mailscanner.html).

Support MailScanner development - buy the book off the website!



More information about the MailScanner mailing list