Files
mailx/aliyun/aliyun_test.go
T

57 lines
1.3 KiB
Go
Raw Normal View History

2024-11-20 19:42:07 +08:00
package aliyun_test
import (
"context"
"os"
"testing"
2026-08-15 01:38:05 +08:00
"code.yun.ink/pkg/mailx"
2024-11-20 19:42:07 +08:00
"code.yun.ink/pkg/mailx/aliyun"
)
func TestSend(t *testing.T) {
2026-08-15 01:38:05 +08:00
if testing.Short() {
t.Skip("skip real send in short mode")
2024-11-20 19:42:07 +08:00
}
2026-08-15 01:38:05 +08:00
client := aliyun.New(aliyun.Config{
AccessKeyID: "LTAI5tEQ8L8fmDir8udD3CFr",
AccessKeySecret: "llg9M1U56s2SW5PuerlKPvTB1xYhn0",
Endpoint: "dm.aliyuncs.com",
AccountName: "test@email.aisz.org",
ReplyAddress: "287852692@qq.com",
2024-11-20 19:42:07 +08:00
})
2026-08-15 01:38:05 +08:00
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())
2024-11-20 19:42:07 +08:00
if err != nil {
t.Fatal("resp err", err)
}
t.Log("send success")
}
// func TestSyncStatus(t *testing.T) {
2026-08-15 01:38:05 +08:00
// client := aliyun.New(aliyun.Config{
// AccessKeyID: "LTAI5tEQ8L8fmDir8udD3CFr",
// AccessKeySecret: "llg9M1U56s2SW5PuerlKPvTB1xYhn0",
// Endpoint: "dm.aliyuncs.com",
// AccountName: "test@email.aisz.org",
// ReplyAddress: "287852692@qq.com",
2024-11-20 19:42:07 +08:00
// })
2026-08-15 01:38:05 +08:00
// ctx := context.Background()
// list, err := client.SyncStatus(ctx)
2024-11-20 19:42:07 +08:00
// if err != nil {
// t.Fatal(err)
// }
// t.Log("status:", list)
// }