2023-02-21 20:46:05 +08:00
|
|
|
package mail
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/md5"
|
|
|
|
"fmt"
|
2023-02-21 20:58:53 +08:00
|
|
|
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk"
|
|
|
|
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/requests"
|
2023-02-21 20:46:05 +08:00
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
VERSION = "2021-09-27"
|
|
|
|
)
|
|
|
|
|
|
|
|
var HOST requests.Host = requests.Host{
|
|
|
|
Default: "mail.gaore.com",
|
2023-03-16 20:15:17 +08:00
|
|
|
Func: func(s string, area string) string {
|
2023-02-21 20:46:05 +08:00
|
|
|
var a = map[string]string{
|
|
|
|
requests.RELEASE: "mail.gaore.com",
|
|
|
|
requests.PRE: "mail.gaore.com",
|
|
|
|
requests.TEST: "mail.gaore.com",
|
|
|
|
}
|
|
|
|
return a[s]
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
type Client struct {
|
|
|
|
sdk.Client
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewClient() (client *Client) {
|
|
|
|
client = &Client{}
|
|
|
|
client.InitWithAccessKey("", "", "")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Client) SendEmail(req *PostEmailRequest) (response *PostEmailResponse, err error) {
|
|
|
|
|
|
|
|
now := time.Now().Second()
|
|
|
|
key := "04573fc4c8e01999a0909ab9c00bca5a"
|
|
|
|
signstr := fmt.Sprintf("%d%s", now, key)
|
|
|
|
data := []byte(signstr)
|
|
|
|
has := md5.Sum(data)
|
|
|
|
sign := fmt.Sprintf("%x", has)
|
|
|
|
req.Time = now
|
|
|
|
req.Sign = sign
|
|
|
|
response = CreatePostEmailResponse()
|
|
|
|
err = c.DoAction(req, response)
|
|
|
|
return
|
|
|
|
}
|