1

My PHP GAE app has a Python sub service that receives mail. It's address is email@service-dot-myappname.appspotmail.com

The Python script just breaks down the message and inserts it into the database for processing.

Every so often a bad email is received that the database doesn't like (strange encoding, way too long etc.) so to investigate, I need to go digging in the logs.

My question is, is there a way to have this email address attached in an inbox as well? I don't see anything in the Google docs, but I'm hoping someone else has done something similar?

Warren
  • 1,984
  • 3
  • 29
  • 60

1 Answers1

0

I don't think there's a way to associate it with an inbox as such, but you could have the mails sent to an inbox initially, then auto-forwarded to appspotmail.

Alternatively you could override the default mail handler's post method to log unprocessable email details (or pickle them and write to the datastore for later inspection, or any other suitable action:

import logging
from google.appengine.ext.webapp.mail_handlers import InboundMailHandler


    class MyInboundMailHandler(InboundMailHandler):
    
        def post(self):
            try:
                super(MyInboundMailHandler, self).post()
            except Exception as ex:
                logging.warning('Could not process message because %s.', ex)
                # save the request body or whatever
  
        def receive(self, mail_message):
            # Process message

(code based on this answer)

snakecharmerb
  • 47,570
  • 11
  • 100
  • 153
  • I did think of your first suggestion too. I'm going to go with that because that inbox will also allow me to search and also filter any junk that may come in. – Warren Nov 28 '17 at 02:19