Fail template, move most header fields into template.

This commit is contained in:
Stuart Gathman
2006-05-21 03:30:06 +00:00
parent 528810c31a
commit 99396a1eee
8 changed files with 38 additions and 17 deletions
-3
View File
@@ -166,9 +166,6 @@ def create_msg(q,rcptlist,origmsg=None,template=None):
msg = Message()
msg.add_header('To',sender)
msg.add_header('From','postmaster@%s'%receiver)
msg.add_header('Auto-Submitted','auto-generated (configuration error)')
msg.add_header('X-Mailer','PyMilter-'+Milter.__version__)
msg.set_type('text/plain')
+9 -5
View File
@@ -1,9 +1,13 @@
Auto_whitelist is checked in check_spf(), but check_spf() is not called for
trusted_relay. Hence, mail relayed via trusted relay is not whitelisted.
Should also check auto_whitelist for trusted relay - but need to extract
relay SPF result from Received-SPF or X-Guessed-SPF header field.
Received-SPF header field should show identity that was checked.
FIXME: DSN for Permerror shows 'None' for error.
Check SPF for outgoing mail (including local policy for internal addresses).
This could also solve the second part of the mail from relay problem below.
Whitelisted sender from trusted relay get PROBATION. Need to extracted
SPF result from headers - and in the case of mail internal to relay
(e.g. bmsi.com), supply 'pass' result.
FIXME: DSN for Permerror shows 'None' for error under some condition.
Another metaDSN format:
Subject: Delivery Report
+14 -9
View File
@@ -1,6 +1,9 @@
#!/usr/bin/env python
# A simple milter that has grown quite a bit.
# $Log$
# Revision 1.61 2006/05/17 21:28:07 customdesigned
# Create GOSSiP record only when connection will procede to DATA.
#
# Revision 1.60 2006/05/12 16:14:48 customdesigned
# Don't require SPF pass for white/black listing mail from trusted relay.
# Support localpart wildcard for white and black lists.
@@ -248,7 +251,8 @@ subjpats = (
r'\buser unknown\b',
r'^failed',
r'^echec de distribution',
r'^fallo en la entrega'
r'^fallo en la entrega',
r'\bfehlgeschlagen\b'
)
refaildsn = re.compile('|'.join(subjpats),re.IGNORECASE)
import logging
@@ -1155,6 +1159,7 @@ class bmsMilter(Milter.Milter):
if users and not newaddr and not user.lower() in users:
self.log('REJECT: RCPT TO:',to)
return Milter.REJECT
# FIXME: should dspam_exempt be case insensitive?
if user in block_forward.get(domain,()):
self.forward = False
exempt_users = dspam_exempt.get(domain,())
@@ -1446,7 +1451,7 @@ class bmsMilter(Milter.Milter):
if self.spf and self.mailfrom != '<>':
# check that sender accepts quarantine DSN
msg = mime.message_from_file(StringIO.StringIO(txt))
rc = self.send_dsn(self.spf,msg,'quarantine.txt')
rc = self.send_dsn(self.spf,msg,'quarantine')
del msg
if rc != Milter.CONTINUE:
return rc
@@ -1508,7 +1513,7 @@ class bmsMilter(Milter.Milter):
# check that sender accepts quarantine DSN
self.fp.seek(0)
msg = mime.message_from_file(self.fp)
rc = self.send_dsn(self.spf,msg,'quarantine.txt')
rc = self.send_dsn(self.spf,msg,'quarantine')
if rc != Milter.CONTINUE:
self.fp = None
return rc
@@ -1668,13 +1673,13 @@ class bmsMilter(Milter.Milter):
if self.cbv_needed:
q,res = self.cbv_needed
if res in ('softfail','fail','deny'):
template_name = 'softfail.txt'
template_name = 'softfail'
elif res in ('unknown','permerror'):
template_name = 'permerror.txt'
template_name = 'permerror'
elif res == 'neutral':
template_name = 'neutral.txt'
template_name = 'neutral'
else:
template_name = 'strike3.txt'
template_name = 'strike3'
rc = self.send_dsn(q,msg,template_name)
self.cbv_needed = None
if rc == Milter.REJECT:
@@ -1727,7 +1732,7 @@ class bmsMilter(Milter.Milter):
else:
self.log('CBV:',sender)
try:
template = file(template_name).read()
template = file(template_name+'.txt').read()
except IOError: template = None
m = dsn.create_msg(q,self.recipients,msg,template)
if srs:
@@ -1735,7 +1740,7 @@ class bmsMilter(Milter.Milter):
m.add_header('Message-Id','<%s>'%msgid)
#m.add_header('Sender','"Python Milter" <%s>'%msgid)
m = m.as_string()
print >>open('last_dsn','w'),m
print >>open(template_name+'.last_dsn','w'),m
res = dsn.send_dsn(sender,self.receiver,m)
if res:
desc = "CBV: %d %s" % res[:2]
+3
View File
@@ -1,4 +1,7 @@
To: %(sender)s
From: postmaster@%(receiver)s
Subject: SPF %(result)s (POSSIBLE FORGERY)
Auto-Submitted: auto-generated (sender verification)
This is an automatically generated Delivery Status Notification.
+3
View File
@@ -1,4 +1,7 @@
To: %(sender)s
From: postmaster@%(receiver)s
Subject: Critical SPF configuration error
Auto-Submitted: auto-generated (configuration error)
This is an automatically generated Delivery Status Notification.
+3
View File
@@ -1,4 +1,7 @@
To: %(sender)s
From: postmaster@%(receiver)s
Subject: DELIVERY STATUS (POSSIBLE SPAM)
Auto-Submitted: auto-generated (content analysis)
This is an automatically generated Delivery Status Notification.
+3
View File
@@ -1,4 +1,7 @@
To: %(sender)s
From: postmaster@%(receiver)s
Subject: SPF %(result)s (POSSIBLE FORGERY)
Auto-Submitted: auto-generated (configuration error)
This is an automatically generated Delivery Status Notification.
+3
View File
@@ -1,4 +1,7 @@
To: %(sender)s
From: postmaster@%(receiver)s
Subject: Critical mail server configuration error
Auto-Submitted: auto-generated (configuration error)
This is an automatically generated Delivery Status Notification.