mirror of
https://gitee.com/lauix/HFish
synced 2025-05-11 12:28:02 +08:00
43 lines
1.0 KiB
Go
43 lines
1.0 KiB
Go
package mail
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"net/http"
|
|
"strings"
|
|
"HFish/core/dbUtil"
|
|
"HFish/utils/send"
|
|
"HFish/error"
|
|
)
|
|
|
|
func Html(c *gin.Context) {
|
|
c.HTML(http.StatusOK, "mail.html", gin.H{})
|
|
}
|
|
|
|
/*发送邮件*/
|
|
func SendEmailToUsers(c *gin.Context) {
|
|
emails := c.PostForm("emails")
|
|
title := c.PostForm("title")
|
|
from := c.PostForm("from")
|
|
content := c.PostForm("content")
|
|
|
|
eArr := strings.Split(emails, ",")
|
|
sql := `select status,info from hfish_setting where type = "mail"`
|
|
isAlertStatus := dbUtil.Query(sql)
|
|
info := isAlertStatus[0]["info"]
|
|
config := strings.Split(info.(string), "&&")
|
|
|
|
if from != "" {
|
|
config[2] = from
|
|
}
|
|
|
|
send.SendMail(eArr, title, content, config)
|
|
c.JSON(http.StatusOK, error.ErrSuccessNull())
|
|
}
|
|
/*发送警告邮件*/
|
|
func SendAlertEmailToUsers(title string,content string){
|
|
sql := `select status,info from hfish_setting where type = "alertMail"`
|
|
isAlertStatus := dbUtil.Query(sql)
|
|
info := isAlertStatus[0]["info"]
|
|
config := strings.Split(info.(string), "&&")
|
|
send.SendMail(config[4:], title, content, config)
|
|
} |