Skip to content

Commit

Permalink
Introduce forward() method used in handle_envelope()
Browse files Browse the repository at this point in the history
  • Loading branch information
Mortal committed Jul 5, 2017
1 parent 41c132e commit 5e29e67
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion emailtunnel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,9 @@ def deliver(self, message, recipients, sender):
except smtplib.SMTPServerDisconnected:
pass

def forward(self, original_envelope, message, recipients, sender):
self.deliver(message, recipients, sender)


class SMTPForwarder(SMTPReceiver, RelayMixin):
def __init__(self, receiver_host, receiver_port, relay_host, relay_port):
Expand Down Expand Up @@ -554,6 +557,8 @@ def handle_invalid_recipient(self, envelope, exn):
pass

def handle_envelope(self, envelope, peer):
original_envelope = copy.deepcopy(envelope)

new_subject = self.translate_subject(envelope)
if new_subject is not None:
envelope.message.subject = new_subject
Expand All @@ -574,4 +579,5 @@ def handle_envelope(self, envelope, peer):
if received is not None:
envelope.message.add_received_line(received)

self.deliver(envelope.message, recipients, mailfrom)
self.forward(original_envelope, envelope.message,
recipients, mailfrom)

0 comments on commit 5e29e67

Please sign in to comment.