更新
This commit is contained in:
+16
-29
@@ -4,43 +4,30 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"code.yun.ink/pkg/mailx"
|
||||
"code.yun.ink/pkg/mailx/aws"
|
||||
"code.yun.ink/pkg/mailx/interfaces"
|
||||
)
|
||||
|
||||
// https://ap-northeast-1.console.aws.amazon.com/ses/home?region=ap-northeast-1#/identities
|
||||
|
||||
func TestSend(t *testing.T) {
|
||||
// email:
|
||||
// #区域
|
||||
// AwsRegion: "ap-northeast-1"
|
||||
// #秘钥ID
|
||||
// AwsAccessKeyId: "AKIAU6GD3MNRHKR4RZG5"
|
||||
// #秘钥
|
||||
// AwsSecretAccessKey: "GSdGuFbZlcpVHMODlqeIKr07R/BdTBGeurq0s+4l"
|
||||
// #发件人
|
||||
// Source: "chenlihan@dreaminglife.cn"
|
||||
|
||||
a := aws.NewAws()
|
||||
if testing.Short() {
|
||||
t.Skip("skip real send in short mode")
|
||||
}
|
||||
client := aws.New(aws.Config{
|
||||
AccessKeyID: "AKIAU6GD3MNRHKR4RZG5",
|
||||
AccessKeySecret: "GSdGuFbZlcpVHMODlqeIKr07R/BdTBGeurq0s+4l",
|
||||
Region: "ap-northeast-1",
|
||||
Sender: "chenlihan@dreaminglife.cn",
|
||||
})
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
ini, err := a.SetOption(ctx, interfaces.SetAws(&interfaces.EmailConfigDataAws{
|
||||
AccessId: "AKIAU6GD3MNRHKR4RZG5",
|
||||
AccessSecret: "GSdGuFbZlcpVHMODlqeIKr07R/BdTBGeurq0s+4l",
|
||||
Region: "ap-northeast-1",
|
||||
Sender: "chenlihan@dreaminglife.cn",
|
||||
}))
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err = ini.Send(ctx, interfaces.Message{
|
||||
Form: "chenlihan@dreaminglife.cn",
|
||||
To: []string{"huangxinyun@dreaminglife.cn"},
|
||||
Body: "Hello",
|
||||
Subject: "主题",
|
||||
})
|
||||
err := client.Send(ctx, mailx.NewMessage().
|
||||
From("chenlihan@dreaminglife.cn").
|
||||
To("huangxinyun@dreaminglife.cn").
|
||||
Subject("主题").
|
||||
Body("Hello").
|
||||
Build())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user