Sending e-mails

Sending e-mails in Google App Engine is pretty simple. We have two options if we want to send e-mails:

  • Use the send_mail() function from google.appengine.api.mail
  • Use EmailMessage from the same module

While sending an e-mail you need some information, such as the recipient of the e-mail, the subject of the e-mail, the contents of the message, and so on. All of this can be supplied via keyword arguments.

The following keyword arguments can be supplied while calling the send_mail() function and are equally applicable for the EmailMessage class's constructor:

  • sender: This is the From field. There are some restrictions on it. We'll take a look at this later.
  • to: This is the address of the recipient of the e-mail. This can be a Python list ...

Get Mastering Google App Engine now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.