Book Image

Python for Google App Engine

By : Massimiliano Pippi
Book Image

Python for Google App Engine

By: Massimiliano Pippi

Overview of this book

Table of Contents (15 chapters)
Python for Google App Engine
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Sending notification e-mails


It's very common for web applications to send notifications to the users, and e-mails are a cheap and effective channel for delivering. The Notes application could benefit from a notification system as well: early in this chapter, we modified the shrink image function so that it runs in a task queue. Users receive a response immediately, but the actual job is put in a queue and they don't know if and when shrink operations complete successfully.

As we can send e-mail messages from an App Engine application on behalf of the administrators or users with Google Accounts, we send a message to the user as soon as the shrink operation is completed.

We first import the mail package in the main.py module:

from google.appengine.api import mail

Then we append the following code to the end of the post() method in the ShrinkHandler class:

sender_address = "Notes Team <[email protected]>"
subject = "Shrink complete!"
body = "We shrunk all the images attached to your notes...