You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1012 B

  1. package mail
  2. import (
  3. "crypto/md5"
  4. "fmt"
  5. "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
  6. "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
  7. "time"
  8. )
  9. const (
  10. VERSION = "2021-09-27"
  11. )
  12. var HOST requests.Host = requests.Host{
  13. Default: "mail.gaore.com",
  14. Func: func(s string) string {
  15. var a = map[string]string{
  16. requests.RELEASE: "mail.gaore.com",
  17. requests.PRE: "mail.gaore.com",
  18. requests.TEST: "mail.gaore.com",
  19. }
  20. return a[s]
  21. },
  22. }
  23. type Client struct {
  24. sdk.Client
  25. }
  26. func NewClient() (client *Client) {
  27. client = &Client{}
  28. client.InitWithAccessKey("", "", "")
  29. return
  30. }
  31. func (c *Client) SendEmail(req *PostEmailRequest) (response *PostEmailResponse, err error) {
  32. now := time.Now().Second()
  33. key := "04573fc4c8e01999a0909ab9c00bca5a"
  34. signstr := fmt.Sprintf("%d%s", now, key)
  35. data := []byte(signstr)
  36. has := md5.Sum(data)
  37. sign := fmt.Sprintf("%x", has)
  38. req.Time = now
  39. req.Sign = sign
  40. response = CreatePostEmailResponse()
  41. err = c.DoAction(req, response)
  42. return
  43. }