42 lines
826 B
Go
42 lines
826 B
Go
package mailx
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"code.yun.ink/pkg/mailx/aliyun"
|
|
"code.yun.ink/pkg/mailx/aws"
|
|
"code.yun.ink/pkg/mailx/interfaces"
|
|
"code.yun.ink/pkg/mailx/mailgun"
|
|
"code.yun.ink/pkg/mailx/smtp"
|
|
)
|
|
|
|
var platform map[consts.Platform3rdType]interfaces.Email
|
|
|
|
// 注册
|
|
func init() {
|
|
platform = make(map[consts.Platform3rdType]interfaces.Email)
|
|
|
|
// 阿里
|
|
platform[consts.Platform3rdTypeAliyun] = &aliyun.Aliyun{}
|
|
|
|
// AWS
|
|
platform[consts.Platform3rdTypeAws] = &aws.Aws{}
|
|
|
|
// Smtp
|
|
platform[consts.Platform3rdTypeSmtp] = &smtp.Smtp{}
|
|
|
|
// mailgun
|
|
platform[consts.Platform3rdTypeMailgun] = &mailgun.MailGun{}
|
|
|
|
}
|
|
|
|
func GetPlatform(ctx context.Context, plat consts.Platform3rdType) (interfaces.Email, error) {
|
|
iplat, ok := platform[plat]
|
|
if ok {
|
|
return iplat, nil
|
|
}
|
|
|
|
return nil, errors.New("not found")
|
|
}
|