Stay organized with collections
Save and categorize content based on your preferences.
Package mail provides the means of sending email from an
App Engine application.
Example:
msg:=&mail.Message{Sender:"romeo@montague.com",To:[]string{"Juliet <juliet@capulet.org>"},Subject:"See you tonight",Body:"Don't forget our plans. Hark, 'til later.",}iferr:=mail.Send(c,msg);err!=nil{log.Errorf(c,"Alas, my user, the email failed to sendeth: %v",err)}
SendToAdmins sends an email message to the application's administrators.
Attachment
typeAttachmentstruct{// Name must be set to a valid file name.NamestringData[]byteContentIDstring}
An Attachment represents an email attachment.
Message
typeMessagestruct{// Sender must be set, and must be either an application admin// or the currently signed-in user.SenderstringReplyTostring// may be empty// At least one of these slices must have a non-zero length,// except when calling SendToAdmins.To,Cc,Bcc[]stringSubjectstring// At least one of Body or HTMLBody must be non-empty.BodystringHTMLBodystringAttachments[]Attachment// Extra mail headers.// See https://cloud.google.com/appengine/docs/standard/go/mail/// for permissible headers.Headersmail.Header}
A Message represents an email message.
Addresses may be of any form permitted by RFC 822.
[[["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."],[[["\u003cp\u003eThe \u003ccode\u003email\u003c/code\u003e package enables App Engine applications to send emails, using functions like \u003ccode\u003eSend\u003c/code\u003e for general recipients and \u003ccode\u003eSendToAdmins\u003c/code\u003e for sending messages specifically to application administrators.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eMessage\u003c/code\u003e type represents an email with fields for sender, recipients (To, Cc, Bcc), subject, body (both plain text and HTML), attachments, and custom headers.\u003c/p\u003e\n"],["\u003cp\u003eEmail attachments are supported through the \u003ccode\u003eAttachment\u003c/code\u003e type, which includes fields for name, data, and content ID, allowing for file attachments to be sent with the email.\u003c/p\u003e\n"],["\u003cp\u003eWhen creating a \u003ccode\u003eMessage\u003c/code\u003e, you must specify a \u003ccode\u003eSender\u003c/code\u003e who is either an application admin or the currently signed-in user, and ensure at least one recipient slice (To, Cc, Bcc) is filled, except when using the \u003ccode\u003eSendToAdmins\u003c/code\u003e function.\u003c/p\u003e\n"]]],[],null,["# Package google.golang.org/appengine/v2/mail (v2.0.6)\n\n**Note:** To get more information about this package, such as access to older versions, view [this package on pkg.go.dev](https://pkg.go.dev/google.golang.org/appengine/v2/mail). \n\u003cbr /\u003e\n\nPackage mail provides the means of sending email from an\nApp Engine application.\n\nExample: \n\n```go\nmsg := &mail.Message{\n Sender: \"romeo@montague.com\",\n To: []string{\"Juliet \u003cjuliet@capulet.org\u003e\"},\n Subject: \"See you tonight\",\n Body: \"Don't forget our plans. Hark, 'til later.\",\n}\nif err := mail.Send(c, msg); err != nil {\n log.Errorf(c, \"Alas, my user, the email failed to sendeth: %v\", err)\n}\n``` \n\nFunctions\n---------\n\n### func Send\n\n func Send(c https://pkg.go.dev/context.https://pkg.go.dev/context#Context, msg *#google_golang_org_appengine_v2_mail_Message) https://pkg.go.dev/builtin#error\n\nSend sends an email message. \n\n### func SendToAdmins\n\n func SendToAdmins(c https://pkg.go.dev/context.https://pkg.go.dev/context#Context, msg *#google_golang_org_appengine_v2_mail_Message) https://pkg.go.dev/builtin#error\n\nSendToAdmins sends an email message to the application's administrators. \n\nAttachment\n----------\n\n type Attachment struct {\n \t// Name must be set to a valid file name.\n \tName https://pkg.go.dev/builtin#string\n \tData []https://pkg.go.dev/builtin#byte\n \tContentID https://pkg.go.dev/builtin#string\n }\n\nAn Attachment represents an email attachment. \n\nMessage\n-------\n\n type Message struct {\n \t// Sender must be set, and must be either an application admin\n \t// or the currently signed-in user.\n \tSender https://pkg.go.dev/builtin#string\n \tReplyTo https://pkg.go.dev/builtin#string // may be empty\n\n \t// At least one of these slices must have a non-zero length,\n \t// except when calling SendToAdmins.\n \tTo, Cc, Bcc []https://pkg.go.dev/builtin#string\n\n \tSubject https://pkg.go.dev/builtin#string\n\n \t// At least one of Body or HTMLBody must be non-empty.\n \tBody https://pkg.go.dev/builtin#string\n \tHTMLBody https://pkg.go.dev/builtin#string\n\n \tAttachments []#google_golang_org_appengine_v2_mail_Attachment\n\n \t// Extra mail headers.\n \t// See https://cloud.google.com/appengine/docs/standard/go/mail/\n \t// for permissible headers.\n \tHeaders https://pkg.go.dev/net/mail.https://pkg.go.dev/net/mail#Header\n }\n\nA Message represents an email message.\nAddresses may be of any form permitted by RFC 822."]]