help with sending mail in Program

Peter Hansen peter at engcorp.com
Thu Jun 9 07:52:07 EDT 2005


Kent Johnson wrote:
> Tim Roberts wrote:
>> Not exactly like this, you didn't.  The list of destination addresses in
>> SMTP.sendmail must be a sequence, not a string:
> 
> Yes, exactly like that. This is a working module, the only thing I 
> changed to post it was the email address and the name of the SMTP 
> server. SMTP.sendmail() allows a single string as a to address.
> 
>  From the comment in smtplib.py:
>            - to_addrs     : A list of addresses to send this mail to.  A 
> bare
>                             string will be treated as a list with 1 
> address.

Interesting... I suspect this "fix" was made in one of the more recent 
Python versions, since I know that in the past (at least with 1.5.2) a 
string would be treated as a sequence, resulting in many one-character 
destination addresses being used. :-(

(And when I say "I know" this, I mean "I vaguely remember, and I 
wouldn't argue against evidence that I'm wrong". ;-) )

-Peter



More information about the Python-list mailing list