[Zope] Problems decoding MIME parts with CMFMail script "addtoMailFolder_unpack_part"

Michael LaPera mlapera@colorbyte.com
Sat, 15 Jun 2002 09:38:24 -0400


Its a CMF product based on ZMailIn (but it's sorta pointless if it can't 
process multipart MIMES).

More info at: http://www.zope.org/Members/natsukashi/Products/CMFMail

On Friday, June 14, 2002, at 06:37  PM, Sidnei da Silva wrote:

> Whats this CMFMail thing? Were do i find more information about it?
>
> []'s
>
> On Qui 13 Jun 2002 15:11, Michael LaPera wrote:
> | I am using CMFMail to bring email into Zope Members accounts (using 
> CMF
> | 1.2, and QMail).  Everything works great if I just send ONLY plain 
> text
> | messages, put if I send multipart/mixed messages CMFMail chokes and I
> | get a error (in my QMail error logs) that basically says "Problem
> | Connecting to server EOF when reading a line."
> |
> | I tracked it down to this fairly standard MIME decoder
> | "addtoMailFolder_unpack_part " (shown below) which is being called by
> | the main script.  It is choking is when gets to the
> | mimetools.copyliteral(file,outfile) or
> | mimetools.decode(file,outfile,encoding) at the bottom of the
> | script  --- >> see code below.
> |
> | I tried testing for specific and general exceptions, but none where
> | thrown (at least that I could catch).  I commented out the offending
> | mimetool code and printed the file to check the results ---- they look
> | just fine.
> |
> | Does anyone have ANY suggestions.  I'm not really sure what to do next
> | (and I really need to be able to get to the decoded mime parts).  If 
> you
> | need more detail let me know...
> |
> |
> | --Michael LaPera
> |
> | ++++++++++++++++++++++++++++++++++++++++++
> |
> | ## Script (Python) "addtoMailFolder_unpack_part"
> | ##bind container=container
> | ##bind context=context
> | ##bind namespace=
> | ##bind script=script
> | ##bind subpath=traverse_subpath
> | ##parameters=theMail,file,partno
> | ##title=Add man to Mail Folder (unpack_part)
> | ##
> |
> | self = context
> |
> | import mimetools
> | import StringIO
> |
> | headers = mimetools.Message(file)
> | type = headers.getmaintype()
> | if type == 'multipart':
> |      boundary = headers.getparam("boundary")
> |      file.push(boundary)
> |      file.readlines()
> |      while not file.last:
> |          file.next()
> |          partno = partno + 1
> |          self.addtoMailFolder_unpack_part(theMail, file, partno)
> |      file.pop()
> |      return
> |
> | name = headers.getparam("name")
> | subtype = headers.getsubtype()
> | if type=='text' and subtype=='plain' and not name:
> |      # overwrite the body so that we get _only_ the body text.
> |      # (Uses the plain version of the body in all situations.
> |      #  HTML formated body will be in the attachments dictionary)
> |      if theMail['body'] != '':
> |          theMail['body'] = theMail['body'] + '\n--body--\n'
> |      theMail['body'] = theMail['body'] + file.read()
> | else:
> |      if not name:
> |          name = 'part%d' % (partno,)
> |          name = name + '-'+subtype
> |
> |      encoding = headers.getencoding()
> |
> |      outfile = StringIO.StringIO()
> |      if encoding == '7bit':
> |          mimetools.copyliteral(file,outfile)     ###  PROBLEM AREA
> |      else:
> |          mimetools.decode(file,outfile,encoding)     ###  PROBLEM AREA
> |
> |      theMail['attachments'][name]=outfile.getvalue()
> |      outfile.close()
> |
> |
> |
> | _______________________________________________
> | Zope maillist  -  Zope@zope.org
> | http://lists.zope.org/mailman/listinfo/zope
> | **   No cross posts or HTML encoding!  **
> | (Related lists -
> |  http://lists.zope.org/mailman/listinfo/zope-announce
> |  http://lists.zope.org/mailman/listinfo/zope-dev )
>
> --
> Sidnei da Silva (dreamcatcher) <sidnei@x3ng.com.br>
> X3ng Web Technology <http://www.x3ng.com.br>
> GNU/Linux user 257852
> Debian GNU/Linux 3.0 (Sid) 2.4.18-newpmac ppc
>
> TRANSACTION CANCELLED - FARECARD RETURNED
>