Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.027 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'msg': 0.07; 'subject:How': 0.09; 'python': 0.09; 'snippet': 0.09; 'subject:using': 0.09; 'subject:while': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr :python-list': 0.10; 'subject:python': 0.11; "'my": 0.16; 'smtplib': 0.16; 'snippets': 0.16; 'subject:mails': 0.16; 'subject:sending': 0.16; "test')": 0.16; 'wrote:': 0.17; 'code,': 0.18; 'import': 0.21; 'cc:2**0': 0.23; "i've": 0.23; 'cc:no real name:2**0': 0.24; 'tried': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'code': 0.31; 'skip:- 30': 0.31; 'you?': 0.32; 'addresses': 0.32; 'skip:- 10': 0.32; 'hi,': 0.33; 'ist': 0.33; 'received:google.com': 0.34; 'text': 0.34; 'thanks': 0.34; 'smtp': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'add': 0.36; 'should': 0.36; 'does': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'received:209.85.214': 0.39; 'address': 0.60; 'from:no real name:2**0': 0.60; 'ein': 0.61; 'stand': 0.61; '30,': 0.62; 'here': 0.65; 'subject': 0.66; 'receive': 0.71; 'tel': 0.75; "'test'": 0.84; 'bcc': 0.84; 'cindy': 0.84; 'received:209.85.214.184': 0.84; 'received:mail-ob0-f184.google.com': 0.84; 'mails': 0.88; 'subject:add': 0.91 Newsgroups: comp.lang.python Date: Thu, 29 Nov 2012 17:30:27 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=158.145.224.34; posting-account=pTuKYQoAAAAmIHz3O4YmoCDALU-hULTt References: <46da4e770809300727j368a27b8qc570a8451a53e470@mail.gmail.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 158.145.224.34 MIME-Version: 1.0 Subject: Re: How to add CC and BCC while sending mails using python From: akegb3@gmail.com To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 60 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1354239036 news.xs4all.nl 6911 [2001:888:2000:d::a6]:47264 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:34084 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