Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: Sending an email with a binary attachment Date: Tue, 1 Mar 2016 04:13:59 +1100 Lines: 19 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de m69V+i7dkKOQCTYWdqinVAEVgrSA0ttUrzGtnFisOmuw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'except:': 0.07; 'cc:addr :python-list': 0.09; '"message': 0.16; '2016': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'sys.exit(0)': 0.16; 'sys.exit(1)': 0.16; 'wrote:': 0.16; 'try:': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'am,': 0.23; 'header:In-Reply- To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; 'subject:Sending': 0.29; 'print': 0.30; 'code': 0.30; 'skip:s 30': 0.31; 'subject:attachment': 0.33; 'tue,': 0.34; 'received:google.com': 0.35; 'replace': 0.35; 'received:209.85': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'subject:with': 0.40; 'here.': 0.62; 'mar': 0.65; 'chrisa': 0.84; 'to:none': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc; bh=sYto1TygvC4EK0qQJN5/Ufd3tpVLAC9qbTujL4+W+nI=; b=ovDH1Q9QpNqh2Y1Sh4fOP02xPYsAdzh0GsBXwbFttgRyhrOQOpV4Kl4Wo/ZJgROEEL pONM83ekUAkxKjUcueq5w89+62l0iaAgI6fVVOb2zA8wU+B/vzsXrMrHcgiy8CvJ2ImL OH41iJ3lUstc3MK5Ee5rSq4IXbF3TOB+QMZwVVzakTF5rDk8r7OVh/c4g8v2VPgl/Qbk sx/9W69pBu4cfXcmNrFQf6Ef7i7UWHkwe1OD/P5uGSbOA0B71CWMP0d6NmAJasJtShN4 WAYeSu4MnTedpuANF7984jg6faYFbOZTftqwHI0x4XnVXV6VT5dUgLdbK2gZWUXsqvDx CUSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc; bh=sYto1TygvC4EK0qQJN5/Ufd3tpVLAC9qbTujL4+W+nI=; b=H/0LrposKukE5CdQ1CoufaoTh3MwIx4lubZTDDjMpWGZN12cRd8Ab/isXMD1uN3Q2p 82Ex2WnrU91KG1pNtiIAT4A2wf9fThAtYDep6+dR1nFyXEyOGWCC6fjXxBANPEYg3tjp dFDY39W6uxVn7RAA4ub2vyrAE3zQizx/M+MocB0ypRea4ro8jm7JNAHRCtgcOlVjC7kp +/aGbtAxMUQ2BDd2YKzO8gB50AEDjmrREaEKjPcbC28USk6W2RJAya0q4351Qhkf/LeT LiOLlpNyCqmamilyQu9/ek8tD/S+JqBAtTch+pgIQ0PSAGfl5iBuCTwAIy7w9Wpld71f iUfw== X-Gm-Message-State: AD7BkJKbU/5jWGLpf66Uqj4WiT7ScESJ3om8Y11vt6kWX9rHWte1ZYMgYHDdd3+nkWXbLJBDm2sFjHPgJjipjg== X-Received: by 10.25.90.21 with SMTP id o21mr4752161lfb.166.1456766039724; Mon, 29 Feb 2016 09:13:59 -0800 (PST) In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:103737 On Tue, Mar 1, 2016 at 4:08 AM, Peter Pearson wrote: > try: > smtp.sendmail(message['From'], > message['To'], > message.as_string()) > except: > print "Message sending has failed" > sys.exit(1) > print "Message sending was successful" > sys.exit(0) > This is the problem, right here. Replace this code with: smtp.sendmail(message['From'], message['To'], message.as_string()) ChrisA