51 lines
		
	
	
		
			1012 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			51 lines
		
	
	
		
			1012 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package mail
 | 
						|
 | 
						|
import (
 | 
						|
	"crypto/md5"
 | 
						|
	"fmt"
 | 
						|
	"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
 | 
						|
	"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
 | 
						|
	"time"
 | 
						|
)
 | 
						|
 | 
						|
const (
 | 
						|
	VERSION = "2021-09-27"
 | 
						|
)
 | 
						|
 | 
						|
var HOST requests.Host = requests.Host{
 | 
						|
	Default: "mail.gaore.com",
 | 
						|
	Func: func(s string) string {
 | 
						|
		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
 | 
						|
}
 |