| 1 | package dm |
| 2 | |
| 3 | import ( |
| 4 | "os" |
| 5 | "strconv" |
| 6 | "testing" |
| 7 | ) |
| 8 | |
| 9 | func TestBatchMail(t *testing.T) { |
| 10 | ID := os.Getenv("ALI_DM_ACCESS_KEY_ID") |
| 11 | SECRET := os.Getenv("ALI_DM_ACCESS_KEY_SECRET") |
| 12 | accountName := os.Getenv("ALI_DM_ACCOUNT_NAME") |
| 13 | templateName := os.Getenv("ALI_DM_TEMPLATE_NAME") |
| 14 | receiverName := os.Getenv("ALI_DM_RECEIVER_NAME") |
| 15 | client := NewClient(ID, SECRET) |
| 16 | err := client.SendBatchMail(&SendBatchMailArgs{SendEmailArgs: SendEmailArgs{AccountName: accountName, |
| 17 | AddressType: "0"}, |
| 18 | TemplateName: templateName, |
| 19 | ReceiverName: receiverName}) |
| 20 | if nil != err { |
| 21 | t.Error(err.Error()) |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | func TestSingleMail(t *testing.T) { |
| 26 | ID := os.Getenv("ALI_DM_ACCESS_KEY_ID") |
| 27 | SECRET := os.Getenv("ALI_DM_ACCESS_KEY_SECRET") |
| 28 | accountName := os.Getenv("ALI_DM_ACCOUNT_NAME") |
| 29 | replyToAddress, _ := strconv.ParseBool(os.Getenv("ALI_DM_REPLY_TO_ADDRESS")) |
| 30 | toAddress := os.Getenv("ALI_DM_TO_ADDRESS") |
| 31 | client := NewClient(ID, SECRET) |
| 32 | err := client.SendSingleMail(&SendSingleMailArgs{ |
| 33 | SendEmailArgs: SendEmailArgs{ |
| 34 | AccountName: accountName, |
| 35 | AddressType: "0", |
| 36 | }, |
| 37 | ReplyToAddress: replyToAddress, |
| 38 | ToAddress: toAddress}) |
| 39 | if nil != err { |
| 40 | t.Error(err.Error()) |
| 41 | } |
| 42 | } |