View source on GitHub |
Receives a parsed email as it is recevied from an external source.
Inherits From: EmailMessage
, expected_type
google.appengine.api.mail.InboundEmailMessage(
mime_message: typing.Optional[typing.Union[typing.Text, bytes, typing.TextIO, email.
message.Message]] = None,
**kw
)
This class makes use of a date
field and can store any number of additional
bodies. These additional attributes make the email more flexible as required
for incoming mail, where the developer has less control over the content.
Example:
Read mail message from CGI
input.
message = InboundEmailMessage(sys.stdin.read()) logging.info('Received email message from %s at %s', message.sender, message.date) enriched_body = list(message.bodies('text/enriched'))[0]
... Do something with body ...
Attributes | |
---|---|
original
|
Gets the original MIME message from which values were set. |
Methods
CheckInitialized
CheckInitialized()
Ensures that recipients have been specified.
Initialize
Initialize(
**kw
)
IsInitialized
IsInitialized()
Determines if EmailMessage
is properly initialized.
Send
Send(
*args, **kwds
)
ToMIMEMessage
ToMIMEMessage()
ToProto
ToProto()
Performs more conversion of recipient fields to the protocol buffer.
Returns | |
---|---|
The MailMessage protocol version of the mail message, including sender
fields.
|
bodies
bodies(
content_type: typing.Text = None
)
Iterates over all bodies.
Args | |
---|---|
content_type
|
Content type on which to filter. This argument allows you to
select only specific types of content. You can use the base type or
the content type.
For example, |
Yields | |
---|---|
A (content_type, payload) tuple for all bodies of a message, including
the body, HTML, and all alternate_bodies , in that order.
|
check_initialized
check_initialized()
Provides additional checks to ensure that recipients have been specified.
Raises | |
---|---|
MissingRecipientError
|
If no recipients are specified in 'To', 'Cc', or 'Bcc'. |
from_environ
@classmethod
from_environ( environ )
Creates an email message by parsing the HTTP request body in environ
.
Example (WSGI)::
def app(environ, start_response): mail_message = mail.InboundEmailMessage.from_environ(request.environ)
# Do something with the message
logging.info('Received greeting from %s: %s' % (mail_message.sender,
mail_message.body))
start_response("200 OK", [])
return “Success”
Args | |
---|---|
environ
|
a WSGI dict describing the HTTP request (See PEP 333). |
Returns | |
---|---|
An InboundEmailMessage object. |
initialize
initialize(
**kw
)
Keyword initialization.
This function sets all fields of the email message using the keyword arguments.
Args | |
---|---|
**kw
|
List of keyword properties as defined by PROPERTIES .
|
is_initialized
is_initialized()
Determines if EmailMessage
is properly initialized.
Returns | |
---|---|
True if the message is properly initialized; otherwise returns False .
|
send
send(
make_sync_call=google.appengine.api.apiproxy_stub_map.MakeSyncCall
)
Sends an email message via the Mail API.
Args | |
---|---|
make_sync_call
|
Method that will make a synchronous call to the API proxy. |
to_mime_message
to_mime_message()
Converts a message to a MIME message.
This function adds additional headers from the inbound email.
Returns | |
---|---|
The MIME message instance of a payload. |
update_from_mime_message
update_from_mime_message(
mime_message
)
Updates the values of a MIME message.
This function copies over date values.
Args | |
---|---|
mime_message
|
The email.Message instance from which you want to copy
information.
|