完善多个通道
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
package aliyun_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"code.yun.ink/pkg/mailx/aliyun"
|
||||
"code.yun.ink/pkg/mailx/interfaces"
|
||||
"github.com/yuninks/loggerx"
|
||||
)
|
||||
|
||||
func TestSend(t *testing.T) {
|
||||
aliyun := &aliyun.Aliyun{}
|
||||
ctx := context.Background()
|
||||
|
||||
logger := loggerx.NewLogger(ctx)
|
||||
|
||||
ali, err := aliyun.InitEmail(ctx, interfaces.EmailConfigData{
|
||||
Aliyun: &interfaces.EmialConfigDataAliyun{
|
||||
AccessId: "LTAI5tEQ8L8fmDir8udD3CFr",
|
||||
AccessKey: "llg9M1U56s2SW5PuerlKPvTB1xYhn0",
|
||||
Endpoint: "dm.aliyuncs.com",
|
||||
AccountName: "test@email.aisz.org", //"test@email.aisz.org",
|
||||
ReplyAddress: "287852692@qq.com",
|
||||
},
|
||||
}, logger)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
by, err := os.ReadFile("../../../static/email/msg/zh_Hant.html")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
fmt.Println(string(by))
|
||||
|
||||
err = ali.Send(ctx, interfaces.Message{
|
||||
To: []string{"huangxinyun@dreaminglife.cn"},
|
||||
Subject: "测试主题",
|
||||
Body: string(by),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal("resp err", err)
|
||||
}
|
||||
|
||||
t.Log("send success")
|
||||
}
|
||||
|
||||
// func TestSyncStatus(t *testing.T) {
|
||||
// aliyun := &aliyun.Aliyun{}
|
||||
// ctx := context.Background()
|
||||
|
||||
// global.Logger = loggerx.NewLogger(ctx)
|
||||
|
||||
// ali, err := aliyun.InitEmail(ctx, interfaces.EmailConfigData{
|
||||
// Aliyun: &interfaces.EmialConfigDataAliyun{
|
||||
// AccessId: "LTAI5tEQ8L8fmDir8udD3CFr",
|
||||
// AccessKey: "llg9M1U56s2SW5PuerlKPvTB1xYhn0",
|
||||
// Endpoint: "dm.aliyuncs.com",
|
||||
// AccountName: "test@email.aisz.org",
|
||||
// ReplyAddress: "287852692@qq.com",
|
||||
// },
|
||||
// })
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
|
||||
// list, err := ali.SyncStatus(ctx)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
|
||||
// _ = list
|
||||
|
||||
// // global.Logger.Infof(ctx, "status: %v", list)
|
||||
|
||||
// t.Log("status:", list)
|
||||
|
||||
// }
|
||||
Reference in New Issue
Block a user