更新
This commit is contained in:
+30
@@ -0,0 +1,30 @@
|
||||
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进行后续操作
|
||||
em.SetOption(ctx, interfaces.SetSmtp(&interfaces.EmailConfigDataSmtp{}))
|
||||
|
||||
err = em.Send(ctx, interfaces.Message{
|
||||
Form: "",
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package mailx
|
||||
|
||||
type Platform3rdType string
|
||||
|
||||
const (
|
||||
Platform3rdTypeAliyun Platform3rdType = "aliyun"
|
||||
Platform3rdTypeAws Platform3rdType = "aws"
|
||||
Platform3rdTypeMailgun Platform3rdType = "mailgun"
|
||||
Platform3rdTypeSmtp Platform3rdType = "smtp"
|
||||
)
|
||||
@@ -1,5 +1,15 @@
|
||||
package interfaces
|
||||
|
||||
|
||||
type EmailType string
|
||||
|
||||
const (
|
||||
EmailTypeAliyun EmailType = "aliyun"
|
||||
EmailTypeAws EmailType = "aws"
|
||||
EmailTypeMailgun EmailType = "mailgun"
|
||||
EmailTypeSmtp EmailType = "smtp"
|
||||
)
|
||||
|
||||
type EmialConfigDataMailgun struct {
|
||||
ApiKey string `json:"api_key"` // mailgun api key
|
||||
Domain string `json:"domain"` // mailgun domain
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
type EmailType string
|
||||
|
||||
|
||||
type EmailInterface interface {
|
||||
SetOption(ctx context.Context, opt ...Option) (EmailInterface, error) // 初始化
|
||||
|
||||
Reference in New Issue
Block a user