Re: How to add CC and BCC while sending mails using python
- From: Bernhard Walle <bernhard.walle@xxxxxx>
- Date: Tue, 30 Sep 2008 18:00:16 +0200
Hi,
* cindy jones [2008-09-30 19:57]:
Can someone tel me how to add cc's and bcc's while sending mails using
python
Following (tested) snippet should help:
------------------ 8< ------------------------------
from smtplib import SMTP
from email.mime.image import MIMEImage
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
to = 'to_address@xxxxxxxxxxxxxxx'
cc = 'cc_address@xxxxxxxxxxxxxxx'
bcc = 'bcc_address@xxxxxxxxxxxxxxx'
msg = MIMEMultipart()
msg['To'] = to
msg['Cc'] = cc
msg['From'] = 'bernhard@xxxxxxxxx'
msg['Subject'] = 'Test'
text = MIMEText('Das ist ein Test')
text.add_header("Content-Disposition", "inline")
msg.attach(text)
s = SMTP('test.smtp.relay')
s.sendmail(msg['From'], [to, cc, bcc], msg.as_string())
s.quit()
------------------ >8 ------------------------------
Regards,
Bernhard
.
- Prev by Date: Re: Python arrays and sting formatting options
- Next by Date: Re: Python arrays and sting formatting options
- Previous by thread: XMLRPC - C Client / Python Server
- Next by thread: how to find out the version of a certain installed package
- Index(es):
Relevant Pages
|