[Mimedefang] allow local aliases w/ md_check_against_smtp_server
Ron Peterson
rpeterso at mtholyoke.edu
Tue Sep 21 16:06:39 EDT 2004
On Tue, Sep 21, 2004 at 09:17:54AM -0400, David F. Skoll wrote:
> On Tue, 21 Sep 2004, Ron Peterson wrote:
>
> > Yeah, I thought about that, but it just seems silly to be reading
> > /etc/aliases over and over every time a new message comes in (this is a
> > pretty busy server, too).
>
> So do it once per slave, in filter_initialize. (Unless your aliases
> file changes often.)
>
> Or better yet, use the Berkeley DB lookup functions to access the alias
> DB directly.
Thanks. Saved me some head scratching. Didn't know about
filter_initialize. That's the method I used - works great. The db
lookup would immediately respond to 'newaliases' updates, but I thought
this would be overall faster. Probably should let the computer work a
little harder so I can be a little lazier, I suppose..
I needed something like this to implement mailman on our our email
gateway.
my %MAIL_ALIAS;
sub init_aliases_hash () {
open( MAIL_ALIASES, "</etc/aliases" ) or die "Can't read /etc/aliases: $!\n";
my $alias;
while( <MAIL_ALIASES> ) {
chomp;
next if /^#/;
next unless /\S+/;
($alias, $val) = $_ =~ /(.*?):(.*)/;
$MAIL_ALIAS{$alias} = $val;
}
close( MAIL_ALIASES );
}
# Called each time a new slave starts.
sub filter_initialize () {
# we can then refer to %MAIL_ALIAS in filter_recipient, below.
init_aliases_hash();
}
sub filter_recipient {
my($recip, $sender, $ip, $host, $first, $helo,
$rcpt_mailer, $rcpt_host, $rcpt_addr) = @_;
my( $sendto );
($sendto) = $recip =~ /<(.*?)\@.*/;
...
if( ! $MAIL_ALIAS{$sendto} ) {
return md_check_against_smtp_server($sender, $recip,
"mgate.mtholyoke.edu",
"mail.mtholyoke.edu");
} else {
return 1;
}
}
--
Ron Peterson
Network & Systems Manager
Mount Holyoke College
More information about the MIMEDefang
mailing list