完善多个通道
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package aws_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"code.yun.ink/pkg/mailx/aws"
|
||||
"code.yun.ink/pkg/mailx/interfaces"
|
||||
"github.com/yuninks/loggerx"
|
||||
)
|
||||
|
||||
// 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"
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
logger := loggerx.NewLogger(ctx)
|
||||
|
||||
mail := aws.Aws{}
|
||||
ini, err := mail.InitEmail(ctx, interfaces.EmailConfigData{
|
||||
Aws: &interfaces.EmailConfigDataAws{
|
||||
AccessId: "AKIAU6GD3MNRHKR4RZG5",
|
||||
AccessSecret: "GSdGuFbZlcpVHMODlqeIKr07R/BdTBGeurq0s+4l",
|
||||
Region: "ap-northeast-1",
|
||||
Sender: "chenlihan@dreaminglife.cn",
|
||||
},
|
||||
}, logger)
|
||||
|
||||
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")
|
||||
}
|
||||
Reference in New Issue
Block a user