Skip to content

Commit

Permalink
Don't forward delivery failures to webfar
Browse files Browse the repository at this point in the history
  • Loading branch information
Mortal committed Dec 9, 2016
1 parent 139ab4c commit ea4ec93
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tutormail/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,19 @@ def __init__(self, *args, **kwargs):

self.exceptions = set()

def reject(self, envelope):
rcpttos = tuple(r.lower() for r in envelope.rcpttos)
subject = str(envelope.message.subject)
return (rcpttos == ('[email protected]',)
and ('Delayed Mail' in subject
or 'Undelivered Mail Returned to Sender' in subject))

def handle_envelope(self, envelope, peer):
if self.reject(envelope):
description = summary = 'Rejected due to reject()'
self.store_failed_envelope(envelope, description, summary)
return

try:
result = super(TutorForwarder, self).handle_envelope(envelope, peer)
django.db.connection.close()
Expand Down

0 comments on commit ea4ec93

Please sign in to comment.