57 lines
1.3 KiB
Go
57 lines
1.3 KiB
Go
package aliyun_test
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"testing"
|
|
|
|
"code.yun.ink/pkg/mailx"
|
|
"code.yun.ink/pkg/mailx/aliyun"
|
|
)
|
|
|
|
func TestSend(t *testing.T) {
|
|
if testing.Short() {
|
|
t.Skip("skip real send in short mode")
|
|
}
|
|
client := aliyun.New(aliyun.Config{
|
|
AccessKeyID: "LTAI5tEQ8L8fmDir8udD3CFr",
|
|
AccessKeySecret: "llg9M1U56s2SW5PuerlKPvTB1xYhn0",
|
|
Endpoint: "dm.aliyuncs.com",
|
|
AccountName: "test@email.aisz.org",
|
|
ReplyAddress: "287852692@qq.com",
|
|
})
|
|
|
|
ctx := context.Background()
|
|
body, err := os.ReadFile("./assets/zh_Hant.html")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log(string(body))
|
|
|
|
err = client.Send(ctx, mailx.NewMessage().
|
|
To("995116474@qq.com").
|
|
Subject("测试主题").
|
|
Body(string(body)).
|
|
Build())
|
|
if err != nil {
|
|
t.Fatal("resp err", err)
|
|
}
|
|
t.Log("send success")
|
|
}
|
|
|
|
// func TestSyncStatus(t *testing.T) {
|
|
// client := aliyun.New(aliyun.Config{
|
|
// AccessKeyID: "LTAI5tEQ8L8fmDir8udD3CFr",
|
|
// AccessKeySecret: "llg9M1U56s2SW5PuerlKPvTB1xYhn0",
|
|
// Endpoint: "dm.aliyuncs.com",
|
|
// AccountName: "test@email.aisz.org",
|
|
// ReplyAddress: "287852692@qq.com",
|
|
// })
|
|
// ctx := context.Background()
|
|
// list, err := client.SyncStatus(ctx)
|
|
// if err != nil {
|
|
// t.Fatal(err)
|
|
// }
|
|
// t.Log("status:", list)
|
|
// }
|