New submission from Xavier Bonaventura <xavibonavent...@gmail.com>: The behavior when you assign an email to 'To' is counter intuitive. When you do:
msg['To'] = 'f...@mail.com' this appends the email instead of really assigning it. This is because the assignment operator is overwritten. Imagine that you have code like this: msg = MIMEText("The report at *link* has been updated") for recipient in recipient_list: msg['To'] = recipient_email server.sendmail(from_address, recipient_email, msg.as_string()) This will send the email to the first person N times, to the second N-1, etc. In case that you want to debug, it is also a problem. In case that the append is the expected behaviour, one would expect that at least if you do a print like this you see the full list. print(msg['To']) Instead of that, in this example of code: msg['To'] = 'f...@mail.com' msg['To'] = 'f...@mail.com' print(msg['To']) It will print: f...@mail.com But the message will be sent two times. ---------- components: Library (Lib) messages: 317550 nosy: Xavier Bonaventura priority: normal severity: normal status: open title: smtplib msg['To] = appends instead of assigning type: behavior versions: Python 2.7 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue33633> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com