This guide describes how to use the Mail API to send and receive mail.
Before you begin
You must register your sender emails as authorized senders. For more information, see who can send email.
Sending mail
To send mail from your application:
Use the
mail.Message
type to set the sender, recipient, subject, and body of the message.Send the email with the
mail.Send
function.
The following example sends an email message to the user as a confirmation that they have created a new account with the application:
Receiving mail
You can set up your app to receive incoming email at addresses in the following format:
anything@appid.appspotmail.com
To receive email:
Enable incoming mail in your app's
app.yaml
file:Set up a handler to process incoming emails, which are supplied to your app as MIME data in an HTTP
POST
request.In your app, register a handler to the
/_ah/mail/
path:In the handler, read the email's data from the
*http.Request
:
You can use the
net/mail
package in the standard library to parse mail messages.