2025-08-30 17:58:23 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
|
|
|
|
"code.yun.ink/pkg/mailx"
|
|
|
|
|
"code.yun.ink/pkg/mailx/interfaces"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
|
|
|
|
|
ctx := context.Background()
|
|
|
|
|
|
|
|
|
|
ch := mailx.Platform
|
|
|
|
|
|
|
|
|
|
em, err := ch.GetEmail(interfaces.EmailTypeSmtp)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
// 使用em进行后续操作
|
2025-08-30 18:14:09 +08:00
|
|
|
em,err = em.SetOption(ctx, interfaces.SetSmtp(&interfaces.EmailConfigDataSmtp{
|
|
|
|
|
Username: "support@email.blueoceanpay.com",
|
|
|
|
|
Password: "SupporT2017",
|
|
|
|
|
ReplyTo: "",
|
|
|
|
|
Host: "smtpdm-ap-southeast-1.aliyun.com",
|
|
|
|
|
Port: "80",
|
|
|
|
|
}))
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
2025-08-30 17:58:23 +08:00
|
|
|
|
|
|
|
|
err = em.Send(ctx, interfaces.Message{
|
2025-08-30 18:14:09 +08:00
|
|
|
Form: "yun@blueoceanpay.com",
|
|
|
|
|
To: []string{"995116474@qq.com"},
|
|
|
|
|
Subject: "Test Email",
|
|
|
|
|
Body: "Hello, this is a test email.",
|
2025-08-30 17:58:23 +08:00
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|