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' , \

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
  File "/usr/local/lib/python2.2/email/Message.py", line 59, in
    g(self, unixfrom=unixfrom)
  File "/usr/local/lib/python2.2/email/Generator.py", line 83, in
  File "/usr/local/lib/python2.2/email/Generator.py", line 104, in
  File "/usr/local/lib/python2.2/email/Generator.py", line 134, in
  File "/usr/local/lib/python2.2/email/Generator.py", line 240, in
    for part in msg.get_payload():
  File "/usr/local/lib/python2.2/email/Message.py", line 151, in
    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?


More information about the Python-list mailing list