Message317588
smtplib doesn't define any behavior for messages. I presume you are talking about the email library?
Vis the print behavior, dict-style lookup is defined to return the first matching header. If you want to see all of them, you can use get_all. For debugging, you should print the whole message, which would show the duplicate headers:
>>> from email.message import Message
>>> msg = Message()
>>> msg['To'] = 'abc@xyz.com'
>>> msg['To'] = 'xyz@abc.com'
>>> print(msg)
To: abc@xyz.com
To: xyz@abc.com
With the new API this is better, at least in terms of debugging:
>>> from email.message import EmailMessage
>>> msg = EmailMessage()
>>> msg['To'] = 'abc@xyz.com'
>>> print(msg)
To: abc@xyz.com
>>> msg['To'] = 'xyz@abc.com'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/rdmurray/python/p38/Lib/email/message.py", line 408, in __setitem__
"in a message".format(max_count, name))
ValueError: There may be at most 1 To headers in a message
This can't be changed in the old API for backward compatibility reasons. |
|
Date |
User |
Action |
Args |
2018-05-24 17:07:26 | r.david.murray | set | recipients:
+ r.david.murray, Xavier Bonaventura |
2018-05-24 17:07:26 | r.david.murray | set | messageid: <1527181646.7.0.682650639539.issue33633@psf.upfronthosting.co.za> |
2018-05-24 17:07:26 | r.david.murray | link | issue33633 messages |
2018-05-24 17:07:26 | r.david.murray | create | |
|