English ▼
Skip to page content Skip to main navigation
e.g. "templates" or "datastore"

# Message Fields

An email message has several fields of information. Fields can be set as keyword arguments to the EmailMessage constructor, as keyword arguments to the initialize() method, or as attributes of an EmailMessage instance. You can create and send a single email message by calling the send_mail() function with the fields as keyword arguments.

An email address can be just the email address (`Albert.Johnson@example.com`) or a formatted name and email address, such as: `Albert Johnson <Albert.Johnson@example.com>` You can provide any formatted name with the sender address or a recipient address, as long as the address meets the requirements. (See RFC 822 for a complete specification for the format of an address and email.utils for information on address parsing.)

The following are the possible fields of an email message:

`sender`
  The email address of the sender, the `From` address. The sender address must be one of the following types:
  - The address of a registered administrator for the application. You can add administrators to an application using the Administration Console.
  - The address of the user for the current request signed in with a Google Account. You can determine the current user's email address with the Users API. The user's account must be a Gmail account, or be on a domain managed by Google Apps.
  - Any valid email receiving address for the app (such as xxx@APP-ID.appspotmail.com).
`to`
  A recipient's email address (a string) or a list of email addresses to appear on the `To:` line in the message header.
`cc`
  A recipient's email address (a string) or a list of email addresses to appear on the `Cc:` line in the message header.
`bcc`
  A recipient's email address (a string) or a list of email addresses to receive the message, but not appear in the message header ("blind carbon copy").
`reply_to`
  An email address to which a recipient should reply instead of the `sender` address, the `Reply-To:` field.
`subject`
  The subject of the message, the `Subject:` line.
`body`
  The plaintext body content of the message.
`html`
  An HTML version of the body content, for recipients that prefer HTML email.
`attachments`

  The file attachments for the message, as a list of two-value tuples, one tuple for each attachment. Each tuple contains a filename as the first element, and the file contents as the second element.

  An attachment file must be one of the allowed file types, and the filename must end with an extension that corresponds with the type. For a list of allowed types and filename extensions, see Overview: Attachments.

`headers`

  The headers for the message, as a dictionary. The keys are the header names, and the corresponding values are the header values.

  A header name must be one of the allowed headers. For a list of allowed header names, see the Mail Service Overview.