smtplib

Steve Holden sholden at holdenweb.com
Mon Apr 16 08:18:06 EDT 2001


"Steve Purcell" <stephen_purcell at yahoo.com> wrote in message
news:mailman.987413782.9074.python-list at python.org...
> Mark Rowe wrote:
> > Hello,
> >
> > what is the correct format for sending the same message to multiple
people,
> > through either multiple to addresses, or cc addresses?
>
> From the library docs:
>
> sendmail (from_addr, to_addrs, msg[, mail_options, rcpt_options])
>       Send mail. The required arguments are an RFC 822 from-address
>       string, a list of RFC 822 to-address strings, and a message string.
>
> So you can pass a sequence of strings as the 'to_addrs' argument:
>
>    s.sendmail('me at here.com',('you at there.com','him at elsewhere.com'),msg)
>
Indeed, even if you only have ONE recipient, the to_addrs argument should be
a list with one element. I haven't checked to see whether a tuple would be
accepted, but there's no real reason why it shouldn't.

For the record, smtpli.SMTP.sendmail() does *not* look at the message
envelope at all: so, for example, you implement blind Cc's by including
recipients in the to_addrs list when they don't appear in the message
headers inside To: or Cc:.

regards
 Steve






More information about the Python-list mailing list