Hi,

I have found many different suggestions on "how to" code python to send a bcc 
email. None of which have worked in my environment - yet. Following is what I 
have at this time, which is erroring. Most of the code I've found will 
successfully send the message to the TO & CC recipients, but not the BCC. Any 
help is very much appreciated. Thx, Ed <Python novice>.

<snip>
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
from smtplib import SMTP

to = 'e...@domain.gov'
cc = 'e...@gmailmail.com'
bcc = 'e...@domain.net'
sender = 'edsb...@domain.gov'

msg = MIMEMultipart()
msg['To'] = to
msg['Cc'] = cc
msg['Subject'] = 'Monthly Report'
msg['From'] = sender

smtp = SMTP("smtp.server.com")
# Start the server:
smtp.ehlo()

# Send the email
smtp.sendmail(sender, [to] + bcc, msg.as_string())

The above generates the following error:
Traceback (most recent call last):
  File "/opt/batch/ebtest/example4.py", line 46, in <module>
    smtp.sendmail(sender, [to] + bcc, msg.as_string())

Other iterations of the code have worked without error, but do not send mail to 
the BCC recipient.

Thanks in advance for any assistance!
~Ed
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to