smtp2web.com: Bridge SMTP to HTTP; Let App Engine accept Email
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 dalmaer@smtp2web.com) and a URL to point too. Of course, if you want an email on your own domain you could alias dalmaer@yourdomain.com to dalmaer@smtp2web.com).
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
June 12th, 2008 at 6:09 pm
thanks for the heads up it looks fairly nice and yes I like my services to be able receive and parse email so this is perfect
regards
John Jones
http://www.johnjones.me.uk
June 14th, 2008 at 2:37 pm
Thanks for the attention!
Just an obligatory note: Though I work at Google, this (obviously) isn’t an official Google project – just something I put together in my own time. :)
July 6th, 2008 at 2:45 am
Hi
I am working on an email app on GAE. How can I enable sending email with other senders than app admins?
Johan
July 25th, 2008 at 4:39 pm
What are the POST parameter names? I am trying to receive the email to a ASP page?
Thanks
July 28th, 2008 at 2:54 am
A silent tongue and true heart are the most admirable things on earth. http://www.laizjj.cn/
August 8th, 2008 at 12:43 pm
Wow! this is truly amazing. I hope google implements this soon ;)
Thank you very much.
August 11th, 2008 at 12:48 am
Though I work at Google, this (obviously) isn’t an official Google project – just something I put together. i am trying to recieved the mail.to a ASP page.