smtp module - specifying multiple email recipients?

Richie Hindle richie at entrian.com
Thu Jul 1 15:01:12 CEST 2004


[Alex]
> I would like to specify several recipients of the email like follows:
> 
>  you = 'recipient1 at some.where,recipient2 at some.where'
>  ...
>  msg['To'] = you
>  ...
>  s.sendmail(me, [you], msg.as_string())
> 
> .. when I execute this code, only recipient1 at some.where gets the email. 

sendmail() takes a list of recipients, not a list with a single
comma-separated string in it.  You need to do this:

  you = ['recipient1 at some.where', 'recipient2 at some.where']
  ...
  msg['To'] = ', '.join(you)
  ...
  s.sendmail(me, you, msg.as_string())

-- 
Richie Hindle
richie at entrian.com





More information about the Python-list mailing list