Sending an email with a binary attachment

Chris Angelico rosuav at gmail.com
Mon Feb 29 12:13:59 EST 2016


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



More information about the Python-list mailing list