import("bytes""fmt""net/http""google.golang.org/appengine""google.golang.org/appengine/log""google.golang.org/appengine/mail")funcconfirm(whttp.ResponseWriter,r*http.Request){ctx:=appengine.NewContext(r)addr:=r.FormValue("email")url:=createConfirmationURL(r)msg:=&mail.Message{Sender:"Example.com Support <support@example.com>",To:[]string{addr},Subject:"Confirm your registration",Body:fmt.Sprintf(confirmMessage,url),}iferr:=mail.Send(ctx,msg);err!=nil{log.Errorf(ctx,"Couldn't send email: %v",err)}}constconfirmMessage=`Thank you for creating an account!Please confirm your email address by clicking on the link below:%s`
メールの受信
アプリでは受信メールを、次の形式のアドレスで受信するように設定できます。
anything@appid.appspotmail.com
メールを受信するには:
アプリの app.yaml ファイル内で受信メールを有効にします。
inbound_services:-mail
HTTP POST リクエストで MIME データとしてアプリに提供される受信メールを処理するハンドラを設定します。