I am receiving inbound email to my Google App Engine app, using a \"standard\" inbound mail handler, following the examples in the docs.
It seems that a certain emai
The error is happening when the inbound mail handler's post
method is called.
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/webapp/mail_handlers.py", line 70, in post
self.receive(mail.InboundEmailMessage(self.request.body))
The simplest solution is to override the post
method in your own handler to trap the error:
import logging
from google.appengine.ext.webapp.mail_handlers import InboundMailHandler
class MyInboundMailHandler(InboundMailHandler):
def post(self):
try:
super(MyInboundMailHandler, self).post()
except LookupError as ex:
logging.warning('Could not process message because %s.', ex)
def receive(self, mail_message):
# Process message
If you don't want to lose the message, you could create and register a custom iso-8859-8-i
codec. This doesn't seem to be a well-documented process, but these questions provide some hints:
How do I properly create custom text codecs?
Custom Python Charmap Codec
how do I write a custom encoding in python to clean up my data?
And the standard library's iso-8859-8 encoding provides a good template.