49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
package aws_test
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"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()
|
|
|
|
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: "主题",
|
|
})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log("send success")
|
|
}
|