I have an app engine app that receives incoming mail with attachments. I check the attachment filename to make sure that the extension is correct. If the filename has umlauts or accented characters in it the encoding makes the filename unreadable to my methods, so I don't know how to check the file type.
For example, if I send a file with name ZumBrückenwirtÜberGrünwaldZurück(2).gpx
And then print out the attachment name like this:
attachments = [message.attachments]
attachmenttype = attachments[0][0][-4:].lower()
logging.error("attachment name %s, %s" % (attachments[0][0], attachmenttype))
I get:
attachment name =?ISO-8859-1?B?WnVtQnL8Y2tlbndpcnTcYmVyR3L8bndhbGRadXL8Y2soMikuZ3B4?=, b4?=