Notice: Over the next few months, we're reorganizing the App Engine documentation site to make it easier to find content and better align with the rest of Google Cloud products. The same content will be available, but the navigation will now match the rest of the Cloud products.

Go 1.16 is now generally available.

Package (v2.0.1)

Package mail provides the means of sending email from an App Engine application.


msg := &mail.Message{
    Sender:  "",
    To:      []string{"Juliet <>"},
    Subject: "See you tonight",
    Body:    "Don't forget our plans. Hark, 'til later.",
if err := mail.Send(c, msg); err != nil {
    log.Errorf(c, "Alas, my user, the email failed to sendeth: %v", err)


func Send

func Send(c context.Context, msg *Message) error

Send sends an email message.

func SendToAdmins

func SendToAdmins(c context.Context, msg *Message) error

SendToAdmins sends an email message to the application's administrators.


type Attachment struct {
	// Name must be set to a valid file name.
	Name      string
	Data      []byte
	ContentID string

An Attachment represents an email attachment.


type Message struct {
	// Sender must be set, and must be either an application admin
	// or the currently signed-in user.
	Sender  string
	ReplyTo string // may be empty

	// At least one of these slices must have a non-zero length,
	// except when calling SendToAdmins.
	To, Cc, Bcc []string

	Subject string

	// At least one of Body or HTMLBody must be non-empty.
	Body     string
	HTMLBody string

	Attachments []Attachment

	// Extra mail headers.
	// See
	// for permissible headers.
	Headers mail.Header

A Message represents an email message. Addresses may be of any form permitted by RFC 822.