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


Groups > comp.lang.python > #33348

Getting "empty" attachment with smtplib

From Tobiah <toby@tobiah.org>
Newsgroups comp.lang.python
Subject Getting "empty" attachment with smtplib
Message-ID <oSQos.17607$h94.1407@newsfe02.iad> (permalink)
Organization TeraNews.com
Date 2012-11-14 09:51 -0800

Show all headers | View raw


I've been sending an email blast out with smtplib and
it's been working fine.  I'm attaching an html doc with

        msg.attach(MIMEText(email, 'html'))

and it displays fine.  Now I need to attach a .pdf
doc, but Thunderbird complains that the attachment
is empty.  When I view the source of the email, the
headers look ok to me, and a large base64 looking
mess follows:

--===============0152408622==
Content-Type: application/pdf
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="tics.pdf"

JVBERi0xLjYNJeLjz9MNCjE0IDAgb2JqDTw8L0xpbmVhcml6ZWQgMS9MIDExNzk1My9PIDE2L0Ug
MTEyNjE3L04gMS9UIDExNzY0My9IIFsgNjA2IDI1M10+Pg1lbmRvYmoNICAgICAgICAgICAgICAg
DQo2MSAwIG9iag08PC9EZWNvZGVQYXJtczw8L0NvbHVtbnMgNS9QcmVkaWN0b3IgMTI+Pi9GaWx0
ZXIvRmxhdGVEZWNvZGUvSURbPDg4RkMxMTM2QjQ3RDhEQzRFMjkxQkEzRDJGNEIyODBBPjxGRTNC
RkM3MjNFMDg3QzRCQUEyNTUzMkM5NEI5QjNCOT5dL0luZGV4WzE0IDc4XS9JbmZvIDEzIDAgUi9M

and so on.  I've tried a few recipes, and this is the one I'm trying now:
  
      pdf = MIMEApplication(pdf_data, 'pdf')
      pdf.add_header('Content-Disposition','attachment', filename = 'tics.pdf')
      msg.attach(pdf)

Any help is appreciated.  Also, if anyone has a working recipe, I'd like to
see it.

Thanks!

Tobiah

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


Thread

Getting "empty" attachment with smtplib Tobiah <toby@tobiah.org> - 2012-11-14 09:51 -0800
  Re: Getting "empty" attachment with smtplib Tobiah <toby@tobiah.org> - 2012-11-14 09:58 -0800
    Re: Getting "empty" attachment with smtplib Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-15 04:54 +0000
    Re: Getting "empty" attachment with smtplib Dieter Maurer <dieter@handshake.de> - 2012-11-15 08:37 +0100
      Re: Getting "empty" attachment with smtplib Tobiah <toby@tobiah.org> - 2012-11-15 09:26 -0800

csiph-web