New submission from Adrien Saladin <[email protected]>:
Hi,
The following script shows two problems with email.mime.text.MIMEText:
- first the use of msg['To'] seems confusing because its dictionnary-like
syntax made me think it acts as a "set or replace", but in fact is working as a
stream operation
- second this behavior allows for the same field to be repeated several times
in a header which is discouraged in rfc-822 and forbidden for many fields in
rfc-2822.
#########################################"
from email.mime.text import MIMEText
msg = MIMEText("""Hello World""")
dest = ["[email protected]", "[email protected]", "[email protected]",
"[email protected]"]
for d in dest:
msg["From"] = "[email protected]"
msg["To"] = d
msg["subject"] = "just a test"
print (msg)
# + send the buggy mail...
###################################
the last sent mail will looks like this:
---------------------
Hello World
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
From: [email protected]
To: [email protected]
subject: just a test
From: [email protected]
To: [email protected]
subject: just a test
From: [email protected]
To: [email protected]
subject: just a test
From: [email protected]
To: [email protected]
subject: just a test
Hello World
----------------------
I see some possible modifications:
* make the [] operator work as a dictionnary-like syntax. So calling msg['To']
multiple times would simply replace the previous 'To:' field. The additional
constraint is that some fields like 'comments' or 'keywords' can be repeated
* (or) throw an error when some fields are repeated in this list:
from, sender, reply-to, to, cc, bcc, message-id, in-reply-to, references,
subject
----------
components: Library (Lib)
messages: 125473
nosy: adrien-saladin
priority: normal
severity: normal
status: open
title: email module should not allow some header field repetitions
versions: Python 2.6, Python 3.1
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue10839>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com