Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #34084 > unrolled thread

Re: How to add CC and BCC while sending mails using python

Started byakegb3@gmail.com
First post2012-11-29 17:30 -0800
Last post2012-11-29 17:30 -0800
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: How to add CC and BCC while sending mails using python akegb3@gmail.com - 2012-11-29 17:30 -0800

#34084 — Re: How to add CC and BCC while sending mails using python

Fromakegb3@gmail.com
Date2012-11-29 17:30 -0800
SubjectRe: How to add CC and BCC while sending mails using python
Message-ID<mailman.375.1354239036.29569.python-list@python.org>
On Tuesday, September 30, 2008 8:00:16 AM UTC-8, Bernhard Walle wrote:
> 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@example.invalid'
> cc = 'cc_address@example.invalid'
> bcc = 'bcc_address@example.invalid'
> 
> msg = MIMEMultipart()
> msg['To'] = to
> msg['Cc'] = cc
> msg['From'] = 'bernhard@bwalle.de'
> 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

Hello Bernhard,

I've tried the above code and the bcc address does not receive the message, on the To & CC addresses receive it. 

Here are snippets from my code, perhaps something will stand out to you?

to = 'ed@domain.gov'
cc = 'ed@gmailmail.com'
bcc = 'ed@home.net'

msg = MIMEMultipart()
msg['To'] = to
msg['Cc'] = cc
msg['Subject'] = 'My Subject text here'
msg['From'] = 'edsboss@domain.gov'

smtp = SMTP("smtpserver")
smtp.ehlo()
smtp.sendmail(msg['From'], [to, cc, bcc], msg.as_string())

Thanks in advance..hope you're still out there!!
~Ed

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web