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


Groups > comp.lang.python > #103781

Re: Sending an email with a binary attachment

Path csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From Anthony Papillion <anthony@cajuntechie.org>
Newsgroups comp.lang.python
Subject Re: Sending an email with a binary attachment
Date Tue, 1 Mar 2016 01:58:17 -0600
Lines 41
Message-ID <mailman.58.1456818869.20602.python-list@python.org> (permalink)
References <mailman.0.1456733421.20602.python-list@python.org> <djjc8gFl1hoU1@mid.individual.net> <CAPTjJmq-Qj9UEg0MNfAWo0CivMcO449=gSA913p4=sN+dp9V8A@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de 7XBQ/6rMonIJWXO4Xf/HkQ/EmMDdAFgRloEWh1pn/LXg==
Return-Path <anthony@cajuntechie.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'skip:p 60': 0.05; 'except:': 0.07; 'pgp': 0.09; 'skip:t 60': 0.09; 'skip:u 60': 0.09; 'exception': 0.13; 'message-----': 0.15; '"message': 0.16; ' -----begin': 0.16; '-----end': 0.16; '2016': 0.16; 'from:addr:anthony': 0.16; 'hash:': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'skip:1 60': 0.16; 'skip:6 60': 0.16; 'skip:j 60': 0.16; 'sys.exit(0)': 0.16; 'sys.exit(1)': 0.16; 'try/except': 0.16; 'wrote:': 0.16; 'try:': 0.18; 'saying': 0.22; 'am,': 0.23; 'bit': 0.23; 'thanks,': 0.24; 'header:In-Reply-To:1': 0.24; 'signed': 0.24; 'header:User-Agent:1': 0.26; 'chris': 0.26; 'block,': 0.29; 'skip:i 60': 0.29; 'subject:Sending': 0.29; "i'm": 0.30; 'print': 0.30; 'code': 0.30; 'skip:s 30': 0.31; 'problem': 0.33; 'subject:attachment': 0.33; 'tue,': 0.34; 'received:10.0': 0.34; 'that,': 0.34; 'besides': 0.35; 'replace': 0.35; 'skip:s 60': 0.35; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'anything': 0.38; 'to:addr:python.org': 0.40; 'subject:with': 0.40; 'here.': 0.62; 'mar': 0.65; 'received:10.0.2': 0.84; 'different.': 0.91
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1
In-Reply-To <CAPTjJmq-Qj9UEg0MNfAWo0CivMcO449=gSA913p4=sN+dp9V8A@mail.gmail.com>
X-Zoho-Virus-Status 1
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:103781

Show key headers only | View raw


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

On 02/29/2016 11:13 AM, Chris Angelico wrote:
> 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())

Hmm, I'm a bit confused. Are you saying that the problem is that I'm
enclosing the code in a Try/Except block? Besides that, I don't see
anything different. If it's the Try/Except block, how do I catch the
exception it might generate if I'm not using the exception block?

Thanks,
Anthony


-----BEGIN PGP SIGNATURE-----

iQIbBAEBCgAGBQJW1UuZAAoJEAKK33RTsEsVdfoP+N/xBIMouhhS1pqInvd9wrk2
jCfjmk7aHQQOdSvtQjXEqdNUu6nPmvX9VRzqvs881bUZAx31usL7VnyzJsL89pZl
PPrXG3WzEDkMaWmfZ45/irGwuP3Cpwkw3h7raDcvA/kV7+jLUBq//1kW7itofPh8
6xKJ9yCJ35vCS4LDhEeIbtMQXRe27QQXeFfi2VjFFRQRQeJlKf0nAd8sH/4q1fPa
IVKy6lgZcDDzCzy0Ux9us8baUOgTjLIY81AKMXGUmXaUNLpDfF6n6RLRtj8fLcN5
sT37okHyRmK9LNwI1PzU8r2p7i3gweDXx4x9g6nqmi6OV8fm4suSd8VOWb8oF1Yb
clQWSvSPE3GcnVaepcixIV1PCF53KsCHaPp63RZbKB3MiPuNTdQQi9Xm1Qfrt0UW
uJiEzfGXavkNRYaShycMB6HJGfjIsCZH9wzf1/irCuhiy+kJbvQq9lhojWw/V0N3
TGwY0Sd/eWqtmcx+u449viDIfLZsJDjzXXsYV60JdZtsSsd5+Mud+vfOlv3s/oy0
EPnIzMJar5LGPghPuab8g7rcXim77hFxS7eLp4j9ugWgRPa8TRpiBb/wx2c8a2e0
122ZW8Fc7+9gxHxSCJdM7GIFChdN2IMogCkERAuTyo+dNP01Mv07eMvSA6JkgiN2
ZlSJ8M9UHRS7dplpJGE=
=nxc8
-----END PGP SIGNATURE-----

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