Nick Johnson, of Google, has created a nice bridge service smtp2web.com: Allow App Engine apps to receive email.

This is perfect timing, as after my App Engine talk in Prague, a nice gent came up to me and asked for just this. He wanted to process email in his application and didn’t think he could.

One shortcoming of purely HTTP-based webapps such as App Engine is

that they can’t receive email. I know that some people are wanting to

create App Engine apps that do this, so I put together a service to

facilitate this. It runs as a standard SMTP server, and sends all the

email it receives via HTTP POST to a user-designated URL. It’s free to

use (but not to abuse)

To use the service, you setup an email account (say [email protected]) and a URL to point too. Of course, if you want an email on your own domain you could alias [email protected] to [email protected]).

Then, you would configure an App Engine controller to receive the email contents:

from google. appengine . ext import webapp import email class EmailHandler ( webapp. RequestHandler ) : def post ( self ) : sender = self . request . GET . get ( "from" , "" ) recipient = self . request . GET . get ( "to" , "" ) message = email . message_from_string ( self . request . body ) # Do stuff with the email message

The code for the service has also been released as open source on Google Code so you can check it out. You will find that it runs as a Twisted application:

from twisted. application import service from twisted. application import internet from twisted. enterprise import adbapi import sys import os sys . path . append ( os . path . dirname ( __file__ ) ) import smtp2web application = service. Application ( "smtp2web Service" ) settings = smtp2web. Settings ( secret_key= "<enter secret key here>" , state_file= "state" , master_host= "localhost:8081" ) smtpServerFactory = smtp2web. ESMTPFactory ( settings ) smtpServerService = internet. TCPServer ( 2025 , smtpServerFactory ) smtpServerService. setServiceParent ( application )

Thanks for doing this Nick!

NOTE: Mailhook is another service (pay) that does something similar