2026-06-19 18:47:36 +08:00
|
|
|
package email
|
2026-06-06 19:31:16 +08:00
|
|
|
|
|
|
|
|
import (
|
2026-07-26 22:19:41 +08:00
|
|
|
"context"
|
2026-06-06 19:31:16 +08:00
|
|
|
|
|
|
|
|
"github.com/ssdomei232/goodBaby/model"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// EmailExecutor 邮件执行器
|
|
|
|
|
type EmailExecutor struct{}
|
|
|
|
|
|
|
|
|
|
func (e *EmailExecutor) GetType() string {
|
2026-07-26 22:19:41 +08:00
|
|
|
return RuleType
|
2026-06-06 19:31:16 +08:00
|
|
|
}
|
|
|
|
|
|
2026-09-12 15:32:27 +08:00
|
|
|
func (e *EmailExecutor) Execute(ctx context.Context, task *model.RuleTask) error {
|
|
|
|
|
account, err := ParseAccountConfig(task.AccountConfig())
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
2026-06-06 19:31:16 +08:00
|
|
|
|
2026-09-12 15:32:27 +08:00
|
|
|
config, err := ParseRuleConfig(task.Rule.ConfigJson)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return SendMail(ctx, account, config)
|
2026-06-06 19:31:16 +08:00
|
|
|
}
|