æ·feat: commplete init process

This commit is contained in:
engigu
2023-12-30 17:40:20 +08:00
parent 9307bec4ab
commit 77af985b76
92 changed files with 12054 additions and 2 deletions
+9
View File
@@ -0,0 +1,9 @@
package message
type DTalkMessage struct {
WebhookUrl string
}
func (d *DTalkMessage) send(content string) {
}
+39
View File
@@ -0,0 +1,39 @@
package message
import (
"fmt"
"gopkg.in/gomail.v2"
)
type EmailMessage struct {
Server string
Port int
Account string
Passwd string
GM *gomail.Dialer
}
func (e *EmailMessage) Init(host string, port int, account string, passwd string) {
e.Server = host
e.Port = port
e.Account = account
e.Passwd = passwd
e.GM = gomail.NewDialer(host, port, account, passwd)
}
func (e *EmailMessage) SendTextMessage(toEmail string, title string, content string) string {
m := gomail.NewMessage()
m.SetHeader("From", e.Account)
m.SetHeader("To", toEmail)
m.SetHeader("Subject", title)
m.SetBody("text/html", content)
if err := e.GM.DialAndSend(m); err != nil {
return fmt.Sprintf("邮件发送失败: %s", err)
}
return ""
}
func (e *EmailMessage) SendHtmlMessage(toEmail string, title string, content string) string {
return e.SendTextMessage(toEmail, title, content)
}