Stay organized with collections Save and categorize content based on your preferences.
The mail API provides two ways to send an email message: the mail.send_mail()
function and the EmailMessage
class.
Sending is asynchronous: the mail.send_mail()
function and the EmailMessage.send()
method transmit the message data to the mail service, then return. The mail service queues the message, then attempts to send it, retrying if the destination mail server is unavailable. Errors and bounce messages are sent to the sender address for the email message.
You must register your sender emails as authorized senders. For more information, see who can send email.
Sending mail withmail.send_mail()
To send mail using the mail.send_mail()
function, use the fields of the email message as parameters, including the sender, the recipients, the subject and the body of the message. For example:
EmailMessage
To send mail using objects with the EmailMessage
class, pass the fields of the email message to the EmailMessage constructor and use attributes of the instance to update message.
The EmailMessage.send()
method sends the email message represented by the instance's attributes. An application can re-use an EmailMessage
instance by modifying attributes and calling the send()
method again.
The following example demonstrates sending a message to confirm an email address:
Sending bulk mailSee the Bulk mail guidelines for considerations around sending bulk email.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["The mail API offers two methods for sending emails: the `mail.send_mail()` function and the `EmailMessage` class."],["Email sending is asynchronous, meaning the function or method returns immediately after sending the message data to the mail service, which then queues and attempts delivery."],["To use this API you need to register your sender emails as authorized senders."],["The `mail.send_mail()` function takes email fields as parameters, whereas the `EmailMessage` class uses attributes of an instance to construct and send emails."],["This API can only run in first-generation runtimes in the App Engine standard environment."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4