Last active
August 29, 2015 14:14
-
-
Save toomore/1ea2b4db44458097abfe to your computer and use it in GitHub Desktop.
goamz ses first try.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net/mail" | |
"github.com/goamz/goamz/aws" | |
"github.com/goamz/goamz/exp/ses" | |
//"github.com/kr/pretty" | |
) | |
const ( | |
AccessKey string = "..." | |
SecretKey string = "..." | |
) | |
func RFC5322Format(nick, email string) string { | |
result := mail.Address{Name: nick, Address: email} | |
return result.String() | |
} | |
func main() { | |
auth := aws.Auth{ | |
AccessKey: AccessKey, | |
SecretKey: SecretKey, | |
} | |
sesapi := ses.NewSES(auth, aws.USEast) | |
//fmt.Printf("sesapi: %# v", pretty.Formatter(sesapi)) | |
fmt.Println(sesapi) | |
mail := ses.NewEmail() | |
mail.SetSource(RFC5322Format("我.me", "[email protected]")) | |
mail.AddTo(RFC5322Format("Gmail 我", "[email protected]")) | |
message := ses.Message{ | |
Body: ses.Body{Html: ses.Content{Data: "Toomore <b>測試</b>", Charset: "UTF-8"}}, | |
Subject: ses.Content{Data: "Test from goamz 測試中文", Charset: "UTF-8"}, | |
} | |
mail.SetMessage(message) | |
//fmt.Printf("mail: %# v", pretty.Formatter(mail)) | |
err := sesapi.SendEmail(mail) | |
fmt.Println("send: ", err) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment