MIMEText breaking the rules?

  • Thread starter Dale Strickland-Clark
  • Start date
D

Dale Strickland-Clark

The email module's mimetext handling isn't what you might expect from
something that appears to behave like a dictionary.

$ python
Python 2.5 (r25:51908, May 25 2007, 16:14:04)
[GCC 4.1.2 20061115 (prerelease) (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
from email.mime.text import MIMEText
msg = MIMEText("A message")
msg["To"] = "(e-mail address removed)"
msg["To"] = "(e-mail address removed)"
print msg.as_string()
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
To: (e-mail address removed)
To: (e-mail address removed)

A message
Having apparently REPLACED my recipient, what I've ended up with is both of
them.
 
T

Tim Roberts

Dale Strickland-Clark said:
The email module's mimetext handling isn't what you might expect from
something that appears to behave like a dictionary.
...
Having apparently REPLACED my recipient, what I've ended up with is both of
them.

This behavior is documented in Message.Message, from which MIMEText
eventually inherits. If you want to start over, delete the item:

del Msg["To"]

I would have to say that the existing behavior is more intuitive for an
email object.
 
D

Dale Strickland-Clark

Tim said:
Dale Strickland-Clark said:
The email module's mimetext handling isn't what you might expect from
something that appears to behave like a dictionary.
...
Having apparently REPLACED my recipient, what I've ended up with is both
of them.

This behavior is documented in Message.Message, from which MIMEText
eventually inherits. If you want to start over, delete the item:

del Msg["To"]

I would have to say that the existing behavior is more intuitive for an
email object.

Thanks for the info.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,188
Latest member
Crypto TaxSoftware

Latest Threads

Top