Message317550
The behavior when you assign an email to 'To' is counter intuitive.
When you do:
msg['To'] = 'foo@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'] = 'foo@mail.com'
msg['To'] = 'foo@mail.com'
print(msg['To'])
It will print:
foo@mail.com
But the message will be sent two times. |
|
Date |
User |
Action |
Args |
2018-05-24 10:50:33 | Xavier Bonaventura | set | recipients:
+ Xavier Bonaventura |
2018-05-24 10:50:33 | Xavier Bonaventura | set | messageid: <1527159033.13.0.682650639539.issue33633@psf.upfronthosting.co.za> |
2018-05-24 10:50:33 | Xavier Bonaventura | link | issue33633 messages |
2018-05-24 10:50:33 | Xavier Bonaventura | create | |
|