From 21e066fbeae0d0d78832612f28cc12b8c3539d74 Mon Sep 17 00:00:00 2001 From: Paulo Bu Date: Mon, 16 Jun 2014 22:26:27 +0200 Subject: [PATCH] Change _MailMixin.send signature and procedure 1) Add the parameter `envelope_from=None` to be able to modify the envelope from from client code. The former version had `envelope_from` parameter only in `Connection.send` and it was impossible to call from client code without hacking a little. 2) In order to use this parameter, the mail is sent using the `connection` object instead of the `message` object. This also reduce one level of innecesary indirection (`Message.send` only does `connection.send(self)`) --- flask_mail.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/flask_mail.py b/flask_mail.py index a485782..77c857c 100644 --- a/flask_mail.py +++ b/flask_mail.py @@ -429,15 +429,16 @@ def _record(message, app): finally: email_dispatched.disconnect(_record) - def send(self, message): + def send(self, message, envelope_from=None): """Sends a single message instance. If TESTING is True the message will not actually be sent. :param message: a Message instance. + :param envelope_from: Email address to be used in MAIL FROM command. """ with self.connect() as connection: - message.send(connection) + connection.send(message, envelope_from) def send_message(self, *args, **kwargs): """Shortcut for send(msg).