Module: google.appengine.api.mail

Sends email on behalf of the application.

This module provides functions for application developers to provide email services for their applications. The module also provides a few utility methods.

Classes

class AdminEmailMessage: Interface that sends email messages to all administrators via the Mail API.

class Attachment: Attachment object.

class BounceNotification: Encapsulates a bounce notification received by the application.

class EmailMessage: Main interface to the Mail API service.

class EncodedPayload: Wrapper for a payload that contains encoding information.

class Error: Base Mail error type.

class InboundEmailMessage: Receives a parsed email as it is recevied from an external source.

class InvalidAttachmentTypeError: The file type of the attachment is invalid.

class InvalidEmailError: The specified email is invalid.

class InvalidHeaderNameError: The header name is invalid.

class InvalidSenderError: The sender is not permitted to send mail for this application.

class MissingBodyError: A body was not specified in the message.

class MissingRecipientsError: A recipient was not specified in the message.

class MissingSenderError: A sender was not specified in the message.

class MissingSubjectError: The subject was not specified in the message.

class PayloadEncodingError: The payload encoding is unknown.

class UnknownCharsetError: The character set is unknown.

class UnknownEncodingError: The encoding is unknown.

Functions

CheckEmailValid(...): Verifies whether an email is valid.

InvalidEmailReason(...): Determines the reason why an email is invalid.

IsEmailValid(...): Determines whether an email address is invalid.

MailMessageToMIMEMessage(...): Generates a MIMEMultipart message from a MailMessage protocol buffer.

SendMail(...): Sends mail on behalf of the application.

SendMailToAdmins(...): Sends email to administrators on behalf of the application.

check_email_valid(...): Verifies whether an email is valid.

check_headers_valid(...): Checks that headers is a valid dictionary for a header.

invalid_email_reason(...): Determines the reason why an email is invalid.

invalid_headers_reason(...): Determines the reason why a header is invalid.

is_ascii(...): Returns whether a string is in ASCII.

is_email_valid(...): Determines whether an email address is invalid.

mail_message_to_mime_message(...): Generates a MIMEMultipart message from a MailMessage protocol buffer.

send_mail(...): Sends mail on behalf of the application.

send_mail_to_admins(...): Sends email to administrators on behalf of the application.

BOUNCE_NOTIFICATION_URL_PATH '/_ah/bounce'
ERROR_MAP

{
 2: <class 'google.appengine.api.mail_errors.BadRequestError'>,
 3: <class 'google.appengine.api.mail_errors.InvalidSenderError'>,
 4: <class 'google.appengine.api.mail_errors.InvalidAttachmentTypeError'>,
 5: <class 'google.appengine.api.mail_errors.InvalidHeaderNameError'>
}

EXTENSION_BLACKLIST ['ade', 'adp', 'bat', 'chm', 'cmd', 'com', 'cpl', 'exe', 'hta', 'ins', 'isp', 'jse', 'lib', 'mde', 'msc', 'msp', 'mst', 'pif', 'scr', 'sct', 'shb', 'sys', 'vb', 'vbe', 'vbs', 'vxd', 'wsc', 'wsf', 'wsh']
EXTENSION_MIME_MAP

{
 'aif': 'audio/x-aiff',
 'aifc': 'audio/x-aiff',
 'aiff': 'audio/x-aiff',
 'asc': 'text/plain',
 'au': 'audio/basic',
 'avi': 'video/x-msvideo',
 'bmp': 'image/x-ms-bmp',
 'c': 'text/plain',
 'css': 'text/css',
 'csv': 'text/csv',
 'diff': 'text/plain',
 'doc': 'application/msword',
 'docx': 'application/msword',
 'flac': 'audio/flac',
 'gif': 'image/gif',
 'gzip': 'application/x-gzip',
 'htm': 'text/html',
 'html': 'text/html',
 'ics': 'text/calendar',
 'jpe': 'image/jpeg',
 'jpeg': 'image/jpeg',
 'jpg': 'image/jpeg',
 'kml': 'application/vnd.google-earth.kml+xml',
 'kmz': 'application/vnd.google-earth.kmz',
 'log': 'text/plain',
 'm4a': 'audio/mp4',
 'mid': 'audio/mid',
 'mov': 'video/quicktime',
 'mp3': 'audio/mpeg',
 'mp4': 'video/mp4',
 'mpe': 'video/mpeg',
 'mpeg': 'video/mpeg',
 'mpg': 'video/mpeg',
 'odp': 'application/vnd.oasis.opendocument.presentation',
 'ods': 'application/vnd.oasis.opendocument.spreadsheet',
 'odt': 'application/vnd.oasis.opendocument.text',
 'oga': 'audio/ogg',
 'ogg': 'audio/ogg',
 'ogv': 'video/ogg',
 'patch': 'text/plain',
 'pdf': 'application/pdf',
 'png': 'image/png',
 'pot': 'text/plain',
 'pps': 'application/vnd.ms-powerpoint',
 'ppt': 'application/vnd.ms-powerpoint',
 'pptx': 'application/vnd.ms-powerpoint',
 'qt': 'video/quicktime',
 'rmi': 'audio/mid',
 'rss': 'text/rss+xml',
 'snd': 'audio/basic',
 'sxc': 'application/vnd.sun.xml.calc',
 'sxw': 'application/vnd.sun.xml.writer',
 'text': 'text/plain',
 'tif': 'image/tiff',
 'tiff': 'image/tiff',
 'txt': 'text/plain',
 'vcf': 'text/directory',
 'wav': 'audio/x-wav',
 'wbmp': 'image/vnd.wap.wbmp',
 'webm': 'video/webm',
 'webp': 'image/webp',
 'xls': 'application/vnd.ms-excel',
 'xlsx': 'application/vnd.ms-excel',
 'zip': 'application/zip'
}

HEADER_WHITELIST

{
 'Auto-Submitted',
 'In-Reply-To',
 'List-Id',
 'List-Unsubscribe',
 'On-Behalf-Of',
 'References',
 'Resent-Date',
 'Resent-From',
 'Resent-To'
}

INCOMING_MAIL_URL_PATTERN '/_ah/mail/.+'