Server.sendmail with no "to_addrs" parameter.

Tim Williams (gmail) tdwdotnet at
Wed Mar 22 12:31:02 CET 2006

On 22 Mar 2006 03:18:41 -0800, EdWhyatt <ed.whyatt at> wrote:
> Hi all, I have searched the group with no answer to this particular
> problem.
> In my sendmail program, I would like to have the ability to send a mail
> message with no-one email address in the To field.
> I do this by adding the mail to the CC field via a header. However, by
> the time I get to the point of sending the mail, my recipient list is
> now empty, so I get the "SMTPRecipientsRefused" error.

 You are making the common mistake of thinking that the header recipients
are the same as the SMTP-envelope recipients,   in reality they do not have
to bear any similarity or relationship :)

You need a single list containing *all* the recipients by email address,
and strings containing the text representations of the header From, To and
Cc fields.

HOST = ''
SENDER = "you at"
RECIPS =  ["joe at","support at","sales at"]
FROM = '  "you at" <you at> '
TO = " none at mydomain.local "
CC = " Uknown recipients "

    import smtplib
   import string, sys
   body = string.join((
   "From: %s" % FROM,
   "To: %s" % TO,
   "Subject: %s" % SUBJECT,
   "CC: %s" % CC,
   BODY), "\r\n")

   server = smtplib.SMTP(HOST)
   server.sendmail(SENDER, RECIPIENTS,body)


HTH :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list