// Copyright 2026 Arctel.net // SPDX-License-Identifier: Apache-2.0 package push import ( pkgmail "Wavelet/pkg/mail" "context" "errors" "fmt" "net" "strconv" ) func init() { Register("email", &EmailPusher{}) } // EmailPusher 基于 pkg/mail 的 SMTP 邮件推送实现 type EmailPusher struct{} // Send 发送邮件 func (p *EmailPusher) Send(ctx context.Context, cfg Config, target string, body map[string]any, _ string, ext map[string]any) (string, error) { if cfg.URL == "" || cfg.Key == "" || cfg.Secret == "" { return "", errors.New("email: SMTP configuration (url, key, secret) is incomplete") } if target == "" { return "", errors.New("email: target email address is required") } title := bodyTitle(body) content := bodyContent(body, "
%s: %v
", "") fromName := "System Notification" if ext != nil { if fn, ok := ext["from_name"].(string); ok && fn != "" { fromName = fn } } htmlBody := fmt.Sprintf(`