python-emails
python-emails copied to clipboard
Provide a convenient way to set Reply-To
Currently, there’s no way to set Reply-To
in the same way as To
, Cc
, or Bcc
:
>>> import emails
>>> ivan = ('Иван', '[email protected]')
>>> maria = ('Марья', '[email protected]')
>>> msg = emails.Message(mail_to=[ivan], cc=[maria], text='Hello world!')
>>> print(msg.as_string())
[...]
To: =?utf-8?b?0JjQstCw0L0=?= <[email protected]>
Cc: =?utf-8?b?0JzQsNGA0YzRjw==?= <[email protected]>
[...]
>>> msg = emails.Message(mail_to=[ivan], reply_to=[maria], text='Hello world!')
Traceback (most recent call last):
File "<ipython-input-13-598375a47f5d>", line 1, in <module>
msg = emails.Message(mail_to=[ivan], reply_to=[maria], text='Hello world!')
TypeError: __init__() got an unexpected keyword argument 'reply_to'
>>> msg = emails.Message(mail_to=[ivan], headers={'Reply-To': [maria]}, text='Hello world!')
>>> print(msg.as_string())
[...]
Reply-To: ,
To: =?utf-8?b?0JjQstCw0L0=?= <[email protected]>
[...]
A reply_to
parameter to emails.Message
(and emails.html
, etc.) would be nice.
relates to #73
This seems possible using the undocumented headers
option:
In [10]: print(emails.Message(mail_to="[email protected]", text="hi", headers={"Reply-To": "[email protected]", "Return-Path": "[email protected]"}).as_string())
Content-Type: multipart/mixed; boundary="===============1059280084=="
MIME-Version: 1.0
Date: Mon, 18 Dec 2017 09:15:46 +0100
Reply-To: [email protected]
Return-Path: [email protected]
To: [email protected]
Not sure if this is the right way, but I think headers
should really be documented, if it is.