12 Apr 2008

The Google App Engine Mail API lets you easily send email from your applications. However, I found it difficult to test it locally when using the Development Web Server.

The documentation states that you can either use an existing SMTP provider or sendmail with the local server but the former solution didn't work for me with GMail or the SMTP server at my web host. And, from a quick Google search for sendmail, I got the impression that I should stay away from it.

In the end, I opted to use a simple Python-based SMTP server by Les Smithson to debug my mail calls locally.

It's very simple to use:

  1. Download the smtps.py script.
  2. In Terminal, change to the folder you downloaded the script into and run it with python smtps.py <port number>, replacing <port number> with the port you want the SMTP server to listen on.
  3. Start your Google App Engine Dev Web Server with dev_appserver.py --smtp_host=localhost --smtp_port=<port number>.

That's it! Now test your Google App Engine application locally in the Development Web Server and the contents of email messages sent by your application will appear in the Terminal window running the SMTP server.

Add Your Comment

Spam Protection by WP-SpamFree

Testing mail locally with the Google App Engine Development Web Server

  1. Hey, do you think this will work for web designs integrated with joomla at local machines because at times I really cannot check smtp without going to online server

    Web Designer
  2. Thank you very much for a very help tip indeed. I have been trying to get this email option to work all day and did not get anywhere!
    Just one question, now I will not get real emails sent to my email account but if it shows it is successful in the other console that listens to the port then does that mean it is working fine?

    thank you very much…very grateful!

    Nora
  3. Yep, that’s right: you will only see the emails in the console :)

    Aral
  4. Another solution is discussed in the app-engine-patch group
    http://groups.google.de/group/app-engine-patch/browse_thread/thread/1662f95d9cacee24?hl=en
    and perhaps Byron Jones the author of a windows FakeSendmailer will come out with an app-engine version of his program making the whole process of sending real test-emails from your local development dev_appserver.py quite simple

    Konrad Martin
  5. Real Mail with App Engine development server is working now.

    See massage 02 Apr 2009 to Google group app-engine-patch:
    http://groups.google.de/group/app-engine-patch/browse_thread/thread/1662f95d9cacee24

    Konrad Martin
  6. The thread mentioned in comment#5 is pretty long. The solution can be found in posting #18:
    http://groups.google.com/group/app-engine-patch/msg/9cca92df4b993d6c?hl=en
    There I explain step by step how to send email on a windows machine – email sent to a real email account via Byron Jones windows sendmailer.

    Konrad Martin
  7. I noticed that this is not the first time you write about the topic. Why have you chosen it again?

    How to Get Six Pack Fast
  8. Can this be used on appengine server?

    aleksandar
  9. You can send mail through GMail’s SMTP server if you patch the development server’s mail stub. A simple solution is described here:

    http://stackoverflow.com/questions/968445/error-while-sending-email

    David Underhill
  10. I’m afraid this advice is out-of-date – or at least it is not applicable for the Java development server. The Java Development Server doesn’t send email at all, just prints out to a log:

    http://code.google.com/appengine/docs/java/mail/overview.html#Development_Server

    This is, of course, rather disappointing.

    Josh Rehman