REPOST: long lines in HTML attachments

Iddo idoerg at cc.huji.ac.il
Thu Dec 27 05:03:14 EST 2001


Hi,

I am trying to use smtplib and mimecntl to email an attached html
document. The trouble is that the html document contains some very
long physical lines (500 chars). It is important that those lines be
preserved as such, since I use <pre> formatting in the htdoc. Some
mail clients (e.g. Pine 4.40) truncate or insert a linefeed in those
lines, creating a mess. Any way of attaching my long-lined files and
getting them through intact? Following is a code snippet of what I do.
Any help would be appreciated.

Thanks,

Iddo
---------------------------------- CUT HERE --------------------------


def email_with_attachments(to_addr, subject, msg_string, attachment):
    f = mimecntl.MIME_document("",type='text/plain')
    f.write(msg_string)
    # Create the message + attachment
    attach = mimecntl.MIME_recoder()
    att_file = open(attachment[1],"r")
    att_stream = att_file.read()
    attach.write(att_stream)
    attach['content-type']=mimecntl.MIMEField('content-type',attachment[0],
                                                   
name=attachment[1])
    attach['content-length']=mimecntl.MIMEField(
                                   'content-length',
                                   len(att_stream))
    attach['content-disposition']=mimecntl.MIMEField(
                                   'content-disposition',
                                   'attachment', 
                                    filename=attachment[1])
    msg = mimecntl.MIME_document((f,attach), 
                                  From='myself at myserver.org',
                                  To=to_addr,Subject=subject)
    # send msg using smtp
    smtp = smtplib.SMTP('localhost')
    smtp.sendmail('myself at myserver.org',to_addr,msg.dump())
    smtp.quit()
if __name__ == '__main__':
    attach_info = ('text/html','/my/html_file.html')
    email_with_attachments('you at youraddress','hi there',attach_info)

========= WAS CANCELLED BY =======:
Path: news.sol.net!spool1-nwblwi.newsops.execpc.com!newsfeeds.sol.net!newspump.sol.net!newsfeed.direct.ca!look.ca!nntp.kreonet.re.kr!feeder.kornet.net!news1.kornet.net!ua4canc3ll3r
From: idoerg at cc.huji.ac.il (Iddo)
Newsgroups: comp.lang.python
Subject: cmsg cancel <7a256ac1.0112270203.77efb6f2 at posting.google.com>
Control: cancel <7a256ac1.0112270203.77efb6f2 at posting.google.com>
Date: Mon, 31 Dec 2001 03:28:01 GMT
Organization: A poorly-installed InterNetNews site
Lines: 2
Message-ID: <cancel.7a256ac1.0112270203.77efb6f2 at posting.google.com>
NNTP-Posting-Host: 211.57.49.2
X-Trace: news2.kornet.net 1009775850 27193 211.57.49.2 (31 Dec 2001 05:17:30 GMT)
X-Complaints-To: usenet at news2.kornet.net
NNTP-Posting-Date: Mon, 31 Dec 2001 05:17:30 +0000 (UTC)
X-No-Archive: yes
X-Unac4ncel: yes
X-Commentary: I love NewsAgent 1.10 and the Sandblaster Cancel Engine Build 74 (19 March 1999)

This message was cancelled from within Mozilla.



More information about the Python-list mailing list