[RFCI-Discuss] refusing mail to abuse@ if not the only recipient
Stuart D. Gathman
stuart at bmsi.com
Tue Dec 1 18:43:11 GMT 2009
> On Mon, 30 Nov 2009, Matus UHLAR - fantomas wrote:
>
> > So, does anyone have a (link to) the code/script/config that could help me
> > to temporarily reject either abuse@ or other recipients?
Here is milter code to check for the number of recipients.
----------------------8<------------------
import Milter
class myMilter(Milter.Base):
## Provide simple logging to sys.stdout
def log(self,*msg):
print 'Milter:',
for i in msg: print i,
print
@noreply
def envfrom(self,f,*str):
self.log("mail from",f,str)
self.recipients = []
def envrcpt(self,to,*str):
# mail to MAILER-DAEMON is generally spam that bounced
for daemon in ('MAILER-DAEMON','auto-notify'):
if to.startswith('<%s@'%daemon):
self.log('REJECT: RCPT TO:',to,str)
self.setreply('550','5.7.1','%s does not accept mail'%daemon)
return Milter.REJECT
self.recipients.append(to)
self.log("rcpt to",to,str)
return Milter.CONTINUE
def data(self);
if len(self.recipients) > 1:
for to in self.recipients:
if to.lower().startswith('<abuse@'):
self.log('TEMPFAIL: abuse')
self.setreply('451','4.7.1','Please email abuse by itself.')
return Milter.TEMPFAIL
return Milter.CONTINUE
--
Stuart D. Gathman <stuart at bmsi.com>
Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154
"Confutatis maledictis, flammis acribus addictis" - background song for
a Microsoft sponsored "Where do you want to go from here?" commercial.
More information about the RFCI-Discuss
mailing list