2023-12-27 18:16:21 +08:00
|
|
|
package mailx
|
|
|
|
|
|
|
|
|
|
import (
|
2024-11-20 19:42:07 +08:00
|
|
|
"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"
|
2023-12-27 18:16:21 +08:00
|
|
|
)
|
|
|
|
|
|
2024-11-20 19:42:07 +08:00
|
|
|
var platform map[consts.Platform3rdType]interfaces.Email
|
2023-12-27 18:16:21 +08:00
|
|
|
|
2024-11-20 19:42:07 +08:00
|
|
|
// 注册
|
|
|
|
|
func init() {
|
|
|
|
|
platform = make(map[consts.Platform3rdType]interfaces.Email)
|
2023-12-27 18:16:21 +08:00
|
|
|
|
2024-11-20 19:42:07 +08:00
|
|
|
// 阿里
|
|
|
|
|
platform[consts.Platform3rdTypeAliyun] = &aliyun.Aliyun{}
|
2023-12-27 18:16:21 +08:00
|
|
|
|
2024-11-20 19:42:07 +08:00
|
|
|
// AWS
|
|
|
|
|
platform[consts.Platform3rdTypeAws] = &aws.Aws{}
|
2023-12-27 18:16:21 +08:00
|
|
|
|
2024-11-20 19:42:07 +08:00
|
|
|
// Smtp
|
|
|
|
|
platform[consts.Platform3rdTypeSmtp] = &smtp.Smtp{}
|
2023-12-27 18:16:21 +08:00
|
|
|
|
2024-11-20 19:42:07 +08:00
|
|
|
// mailgun
|
|
|
|
|
platform[consts.Platform3rdTypeMailgun] = &mailgun.MailGun{}
|
2023-12-27 18:16:21 +08:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-20 19:42:07 +08:00
|
|
|
func GetPlatform(ctx context.Context, plat consts.Platform3rdType) (interfaces.Email, error) {
|
|
|
|
|
iplat, ok := platform[plat]
|
|
|
|
|
if ok {
|
|
|
|
|
return iplat, nil
|
2023-12-27 18:16:21 +08:00
|
|
|
}
|
|
|
|
|
|
2024-11-20 19:42:07 +08:00
|
|
|
return nil, errors.New("not found")
|
2023-12-27 18:16:21 +08:00
|
|
|
}
|