sendmail: correctly parse From headers, if lookup of the sender fails, print the pre-parse value

This commit is contained in:
Benjamin Dauvergne 2012-05-07 12:36:08 +02:00
parent aa83fcfddd
commit 5d8ea1861f
1 changed files with 2 additions and 3 deletions

View File

@ -63,13 +63,12 @@ In case of failure the following return value is returned:
if exit_code:
sys.exit(exit_code)
def handle_mail(self, mail, mail_sender, mail_recipients, **options):
content_errors = []
attachments = []
recipients = []
description = u''
mail_from = mail.get('From')
mail_from = email.utils.parseaddr(mail.get('From'))[1]
tos = mail.get_all('to', [])
ccs = mail.get_all('cc', [])
resent_tos = mail.get_all('resent-to', [])
@ -118,7 +117,7 @@ In case of failure the following return value is returned:
try:
sender = mail_sender or auth_models.User.objects.get(email=mail_from)
except auth_models.User.DoesNotExist:
content_errors.appen('Unable to find an unique sender for the mail %s' % mail_from)
content_errors.append('Unable to find an unique sender for the mail %s' % mail.get('From'))
if content_errors:
msg = [ '7.7.1 The email sent contains many errors:' ]
for error in content_errors: