Re: [Exim] custom SMTP reject messages

Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: Gary Palmer
Fecha:  
A: exim-users
Asunto: Re: [Exim] custom SMTP reject messages
> # /etc/mail/checksender/hostreject
> # Hosts listed in this file are not allowed to send mail to us. List IP ads o
> nly
> # (otherwise you'll trigger a DNS request for each connection)
> 207.38.123.83        "You found it funny to mailbomb us, eh? Go die now"

>
> :-)
>
> I don't think this is yet possible, and the system filter happens too late
> to reject the mail during the SMTP transaction.
>
> Is there a way to emulate what I was doing with sendmail, or not currently?


What I use is:

prohibition_message = "${perl{prohibition_message}{$prohibition_reason}{$sender_host_address}}"

This calls a perl routine (prohibition_message), which I currently
have set so that it can lookup different tables based on the type of
rejection. Right now its only set for relay refused, but it can be
expanded.

Here is the perl:

sub
prohibition_message {
my ($reason, $ip) = @_;

  if ($reason eq "host_accept_relay") {
    my $lookup = '${lookup{'.$ip.'}cdb{/shared/exim/prohibition_message.cdb}{${expand:$value}}}';
    my $result = Exim::expand_string($lookup);
    return $result if ($result);
  }


# this will cause the normal message to be output with no additions.
return "";
}

Yes, its kinda gross, it calls back into exim to do the
lookup/expansion of the rejection message. But it works :)

Its expandable to have a lot of different functions if you so desire.
This is tested and working in exim 3.16 currently, though I imagine
it'd work in exim 3.2x also