diff --git a/pkgs/email/email.go b/pkgs/email/email.go index 627dff9..e5da6e6 100644 --- a/pkgs/email/email.go +++ b/pkgs/email/email.go @@ -13,7 +13,6 @@ import ( type Client struct { dialer *gomail.Dialer - from string host string port int username string @@ -26,7 +25,6 @@ func (self *Client) NewSMTPClient() (*Client, error) { port := viper.GetInt("email.port") user := viper.GetString("email.username") pass := viper.GetString("email.password") - from := viper.GetString("email.from") security := strings.ToLower(viper.GetString("email.security")) insecure := viper.GetBool("email.insecure_skip_verify") @@ -45,7 +43,6 @@ func (self *Client) NewSMTPClient() (*Client, error) { InsecureSkipVerify: insecure, } - // 安全传输协议配置 switch security { case "ssl": dialer.SSL = true @@ -60,7 +57,6 @@ func (self *Client) NewSMTPClient() (*Client, error) { return &Client{ dialer: dialer, - from: from, host: host, port: port, username: user, @@ -69,13 +65,13 @@ func (self *Client) NewSMTPClient() (*Client, error) { }, nil } -func (c *Client) Send(to, subject, html string) (string, error) { +func (c *Client) Send(from, to, subject, html string) (string, error) { if c.dialer == nil { return "", errors.New("SMTP dialer not initialized") } m := gomail.NewMessage() - m.SetHeader("From", c.from) + m.SetHeader("From", from) m.SetHeader("To", to) m.SetHeader("Subject", subject) m.SetBody("text/html", html) diff --git a/service/auth/magic.go b/service/auth/magic.go index af0e990..c524d4b 100644 --- a/service/auth/magic.go +++ b/service/auth/magic.go @@ -70,6 +70,7 @@ func Magic(c *gin.Context) { return } emailClient.Send( + "NixCN CMS ", req.Email, "NixCN CMS Email Verify", "

Click the link below to verify your email. This link will expire in 10 minutes.

"+url.String()+"",