Sending emails to 3 addresses....

Tim Williams tim at tdw.net
Fri Mar 30 09:08:40 EDT 2007


On 30/03/07, Boudreau, Emile <Emile.Boudreau at cognos.com> wrote:
>
> sendMail('this is the subject line', 'the results: 71 fails, 229 pass, 300
> total.', 'user1 at mycompany.com, user2 at mycompany.com, user3 at mycompany.com')
>
> def sendMail(subject, body, TO, FROM="machine at mycompany.com"):
>     print TO
>     HOST = "exchange.mycompany.com"
>     BODY = string.join((
>         "From: %s" % FROM,
>         "To: %s" % TO,
>         "Subject: %s" % subject,
>         "",
>         body
>         ), "\r\n")
>     server = smtplib.SMTP(HOST)
>     server.sendmail(FROM, [TO], BODY)
>     server.quit()
>

Emile,

You are passing the TO addresses as 3 addresses in a single string.
[TO] results in a list containing a single string - not a list
containing 3 individual addresses.

You need to either pass the addresses to the function as a list
containing the 3 addresses as individual strings,  or change

[TO]

to

TO.split(',')


HTH :)



More information about the Python-list mailing list