Bug in e-mail package?

paul at nlhas.no paul at nlhas.no
Thu Feb 21 07:51:32 EST 2002


I have a simple e-mail forwarding/filtering module which essentially
does this:

msg = email.message_from_string('\n'.join(pop3connection.retr(xx)[1]))
.....stuff to determine send-to address (without modifying msg)
smtpconnection.sendmail(email.Utils.parseaddr(msg.get('from'))[1], \
			'send-to address' , \
                   	msg.as_string(unixfrom=0))

The thing died when passed a piece of e-mail spam, producing the
following trailback:

===================================================================
  File "/home/public/nlh/nlhapp/utils/message/postman.py", line 49, in
processmail
    msg.as_string(unixfrom=0))
  File "/usr/local/lib/python2.2/email/Message.py", line 59, in
as_string
    g(self, unixfrom=unixfrom)
  File "/usr/local/lib/python2.2/email/Generator.py", line 83, in
__call__
    self._write(msg)
  File "/usr/local/lib/python2.2/email/Generator.py", line 104, in
_write
    self._dispatch(msg)
  File "/usr/local/lib/python2.2/email/Generator.py", line 134, in
_dispatch
    meth(msg)
  File "/usr/local/lib/python2.2/email/Generator.py", line 240, in
_handle_multipart
    for part in msg.get_payload():
  File "/usr/local/lib/python2.2/email/Message.py", line 151, in
__getitem__
    return self.get(name)
  File "/usr/local/lib/python2.2/email/Message.py", line 214, in get
    name = name.lower()
AttributeError: 'int' object has no attribute 'lower'
===================================================================

I see nothing in the spam that could have caused this (integer header
identifier presumably), but have no doubt that there is something
nasty in there. On the other hand it's a bit worrying that the e-mail
module lets itself be knocked out by this. Or is it? Comments?

pm



More information about the Python-list mailing list