[Mimedefang] md_check_against_smtp_server

John Nemeth jnemeth at victoria.tc.ca
Fri Jun 3 18:33:38 EDT 2005


On Oct 24,  7:56am, Tory Blue wrote:
}
} md_check_against_smtp_server($sender, $rcpt_addr, $MyFilterHostName,
} $rcpt_host);aid: $msg.
} 
} So I have started to use md_check and it's sort of working. It appears to be
} checking the internal server and getting the right results, the problem,
} large problem, is the system appears to be bouncing after the fact, vs
} return action_bounce, where my front end server would tell the connecting
} host, to go fly a kite,  not a valid user.
} 
} I don't want to accept and bounce, that is the point of this option, but
} that's what it's doing. Or it's in fact not working correctly, however my
} unix front ending a 2003 server, would not show user unknowns in the mail
} log, that the exchange server would only know about if it was not doing the
} checks.
} 
} So I have to believe that my unix host is making the call to the internal
} server and getting the OK (it then sends) or user unknown and it starts it's
} little bounce process, instead of rejecting during the smtp session.. 
} 
} What's going on? How Is this suppose to work, I need upon a "user unknown",
} to action_bounce, not REJECT (which appears to be an accept and bounce and
} that is unacceptable.
} 
} Any idea what I'm doing wrong, is there a way to change the behaviour?

     There are several problems with your filter (see below).

} Using Larry Schumacher's example.
} 
} sub filter_initialize {
} 
}   require DB_File;
}   use Fcntl;
}   tie %relaydomains, "DB_File", "/etc/mail/mailertable.db", O_RDONLY;
} }
} 
} sub filter_recipient {
} 
}   my($recip, $sender, $ip, $host, $first, $helo, $rcpt_mailer, $rcpt_host,
} $rcpt_addr) = @_;
} 
}   ($user,$domain) = split /\@/, $recip;

     This is not the proper way to parse $recip.  First, if an SMTP
client is following the RFCs then it will send the command,

RCTP To:<user at domain>

Sendmail passes everything after the ':' to a milter.  In this case,
the milter is MIMEDefang, which in turn passes it to you.  Using your
parsing, $domain will end up containing "domain>" (notice the '>' on
the end), which, of course, won't match anything in your mailertable.
The second issue is that according to the DNS RFCs domain names are
case insensitive.  This means that if somebody were to send mail to
Responsys.com the mail would reach you but your lookup would fail.  The
proper way to parse $recip looks more like this (somebody else may be
able to optimize it a bit more, but this works; my mimedefang-filter is
my first Perl project):

    $recip =~ tr/<>//d;
    $user = $recip;
    $user =~ s/(^.*)\@.*/$1/;
    $domain = lc $recip;
    $domain =~ s/.*\@(.*$)/$1/;
    $fulladdr = $user . '@' . $domain;

Also, you may want to create log entries so that you can see exactly
what is happening, i.e.:

    md_syslog("debug", $QueueID . ", filter_recipient:  \$user is $user and \$domain is $domain");

}   if( $relaydomains{$domain} =~ /^smtp:\[(.+)\]/){
}     return md_check_against_smtp_server($sender, $recip, "mymailhost", $1);

     You may want to put the results of md_check_against_smtp_server() into
a variable so that you can log it and then do a return $variable.

}   } else {

     Possibly add another log entry here:

    md_syslog("debug", $QueueID . ", filter_recipient:  recipient not checked");

}     return ("CONTINUE", "OK");
}   }
} }
} 

     BTW, about the log entries you sent in another message.  The entry
showing your Exchange server rejecting the user isn't from when your
mimedefang_filter used md_check_against_smtp_server(), but rather from
when sendmail attempted to forward the message after accepting it.  At
that point, sendmail had no choice but to generate a bounce message.

}-- End of excerpt from Tory Blue



More information about the MIMEDefang mailing list