On 22 Mar 2006 03:18:41 -0800, EdWhyatt <
[EMAIL PROTECTED]> wrote:
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 = '127.0.0.1'
SENDER = "[EMAIL PROTECTED]"
RECIPS = ["[EMAIL PROTECTED]"," [EMAIL PROTECTED]","[EMAIL PROTECTED]"]
FROM = ' "[EMAIL PROTECTED]" < [EMAIL PROTECTED]> '
TO = " [EMAIL PROTECTED] "
CC = " Uknown recipients "
def send_email(HOST,SENDER, RECIPIENTS, FROM,TO,SUBJECT ,BODY,CC=None):
----------------------------
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 = '127.0.0.1'
SENDER = "[EMAIL PROTECTED]"
RECIPS = ["[EMAIL PROTECTED]"," [EMAIL PROTECTED]","[EMAIL PROTECTED]"]
FROM = ' "[EMAIL PROTECTED]" < [EMAIL PROTECTED]> '
TO = " [EMAIL PROTECTED] "
CC = " Uknown recipients "
def send_email(HOST,SENDER, RECIPIENTS, FROM,TO,SUBJECT ,BODY,CC=None):
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)
server.quit()
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)
server.quit()
----------------------------
HTH :)
-- http://mail.python.org/mailman/listinfo/python-list