Sam Varshavchik wrote:
Bowie Bailey writes:
Bowie Bailey wrote:
I have received a request from one of my users to block emails to
their domain from a particular address. Since I don't want to
block the address from the entire server, I think the place to do
it is from maildrop. What I can't figure out is how to direct
maildrop to bounce the message.
What command can I give to maildrop to make it send a dsn back to
the sender? And can I specify the error message?
To answer my own question, I was able to do it like this:
LCSENDER=tolower($SENDER)
if ( $LCSENDER eq "bloc...@example.com" )
{
echo "This account is not accepting mail from $SENDER"
EXITCODE=64
exit
}
I was going to do a recipient rule and put it in
/etc/courier/maildroprc, but I decided to put it in the individual
user's .mailfilter files instead so that any errors would be
limited to that one domain.
The rule for maildroprc would have looked like this:
LCRECIP=tolower($RECIPIENT)
LCSENDER=tolower($SENDER)
if ( $LCRECIP =~ /@mydomain\.com/ && $LCSENDER eq
"bloc...@example.com" ) {
echo "This account is not accepting mail from $SENDER"
EXITCODE=64
exit
}
Does anyone see any problems with this?
No, that's going to do exactly what you think. The thing is that
anyone can send an E-mail using anyone's return address, to a
malicious entity with advance knowledge of this can use you to flood
this address with bounces.
This is exactly what rcptfilter is designed to do.
Interesting. I wasn't aware of rcptfilter.
The docs are a bit vague on exactly how to use it. It looks like it
uses the maildrop syntax and just produces an exit code. So I can put
the same code from above into .mailfilters/rcptfilter rather than
.mailfilter?
Is there a global version of the rcptfilter, or is it strictly per-user?
As a related question, is my tolower call in the code above necessary or
does courier automatically lowercase the email addresses?