Example #1
0
func (s *S) TestSendEmail(c *check.C) {
	testServer.Response(200, nil, TestSendEmailOk)

	resp, err := s.sesService.SendEmail("*****@*****.**",
		ses.NewDestination([]string{"*****@*****.**", "*****@*****.**"},
			[]string{"*****@*****.**", "*****@*****.**"},
			[]string{"*****@*****.**", "*****@*****.**"}),
		ses.NewMessage("subject", "textBody", "htmlBody"))
	req := testServer.WaitRequest()

	c.Assert(req.Method, check.Equals, "POST")
	c.Assert(req.URL.Path, check.Equals, "/")
	c.Assert(req.Header["Date"], check.Not(check.Equals), "")
	c.Assert(req.FormValue("Source"), check.Equals, "*****@*****.**")
	c.Assert(req.FormValue("Destination.ToAddresses.member.1"), check.Equals, "*****@*****.**")
	c.Assert(req.FormValue("Destination.ToAddresses.member.2"), check.Equals, "*****@*****.**")
	c.Assert(req.FormValue("Destination.CcAddresses.member.1"), check.Equals, "*****@*****.**")
	c.Assert(req.FormValue("Destination.CcAddresses.member.2"), check.Equals, "*****@*****.**")
	c.Assert(req.FormValue("Destination.BccAddresses.member.1"), check.Equals, "*****@*****.**")
	c.Assert(req.FormValue("Destination.BccAddresses.member.2"), check.Equals, "*****@*****.**")

	c.Assert(req.FormValue("Message.Subject.Data"), check.Equals, "subject")
	c.Assert(req.FormValue("Message.Subject.Charset"), check.Equals, "utf-8")

	c.Assert(req.FormValue("Message.Body.Text.Data"), check.Equals, "textBody")
	c.Assert(req.FormValue("Message.Body.Text.Charset"), check.Equals, "utf-8")

	c.Assert(req.FormValue("Message.Body.Html.Data"), check.Equals, "htmlBody")
	c.Assert(req.FormValue("Message.Body.Html.Charset"), check.Equals, "utf-8")

	c.Assert(err, check.IsNil)
	c.Assert(resp.SendEmailResult, check.NotNil)
	c.Assert(resp.ResponseMetadata, check.NotNil)
}
Example #2
0
func (s *S) TestSendEmailError(c *check.C) {
	testServer.Response(400, nil, TestSendEmailError)

	resp, err := s.sesService.SendEmail("*****@*****.**",
		ses.NewDestination([]string{"*****@*****.**"}, []string{}, []string{}),
		ses.NewMessage("subject", "textBody", "htmlBody"))
	_ = testServer.WaitRequest()

	c.Assert(resp, check.IsNil)
	c.Assert(err.Error(), check.Equals, "Email address is not verified. (MessageRejected)")
}