Le package Mail permet d'envoyer des e-mails à partir d'une application App Engine.
Exemple :
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.", } if err := mail.Send(c, msg); err != nil { log.Errorf(c, "Alas, my user, the email failed to sendeth: %v", err) }
Fonctions
func Send
La fonction Send envoie un e-mail.
func SendToAdmins
La fonction SendToAdmins envoie un e-mail aux administrateurs de l'application.
Association
type Attachment struct {
// Name must be set to a valid file name.
Name string
Data []byte
ContentID string
}
Le type Attachment représente une pièce jointe à un e-mail.
Message
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 https://cloud.google.com/appengine/docs/standard/go/mail/
// for permissible headers.
Headers mail.Header
}
Le type Message correspond à un e-mail. Les adresses peuvent se présenter sous les formes autorisées par la norme RFC 822.