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


Groups > comp.lang.python > #103737

Re: Sending an email with a binary attachment

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Chris Angelico <rosuav@gmail.com>
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 <mailman.27.1456766046.20602.python-list@python.org> (permalink)
References <mailman.0.1456733421.20602.python-list@python.org> <djjc8gFl1hoU1@mid.individual.net>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de m69V+i7dkKOQCTYWdqinVAEVgrSA0ttUrzGtnFisOmuw==
Return-Path <rosuav@gmail.com>
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 <djjc8gFl1hoU1@mid.individual.net>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:103737

Show key headers only | View raw


On Tue, Mar 1, 2016 at 4:08 AM, Peter Pearson <pkpearson@nowhere.invalid> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Sending an email with a binary attachment Anthony Papillion <anthony@cajuntechie.org> - 2016-02-29 02:10 -0600
  Re: Sending an email with a binary attachment Peter Pearson <pkpearson@nowhere.invalid> - 2016-02-29 17:08 +0000
    Re: Sending an email with a binary attachment Chris Angelico <rosuav@gmail.com> - 2016-03-01 04:13 +1100
    Re: Sending an email with a binary attachment Grant Edwards <invalid@invalid.invalid> - 2016-02-29 18:22 +0000
    Re: Sending an email with a binary attachment Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-02-29 20:43 -0500
    Re: Sending an email with a binary attachment Anthony Papillion <anthony@cajuntechie.org> - 2016-03-01 01:58 -0600
    Re: Sending an email with a binary attachment Chris Angelico <rosuav@gmail.com> - 2016-03-01 19:03 +1100
    Re: Sending an email with a binary attachment Anthony Papillion <anthony@cajuntechie.org> - 2016-03-01 22:29 -0600

csiph-web