rss/mail/mail.go
2023-07-09 22:57:47 +08:00

37 lines
698 B
Go

package mail
import (
"log"
"os"
"os/exec"
)
func SendMail(subject string, content string, files ...string) {
cm := os.Getenv("mail_cmd_path")
if cm == "" {
return
}
subjectParam := os.Getenv("mail_cmd_subject_param_name")
if subjectParam == "" {
return
}
contentParam := os.Getenv("mail_cmd_content_param_name")
if contentParam == "" {
return
}
fileParam := os.Getenv("mail_cmd_file_param_name")
if fileParam == "" {
return
}
v := []string{subjectParam, subject, contentParam, content}
for _, f := range files {
if f != "" {
v = append(v, fileParam, f)
}
}
cmd := exec.Command(cm, v...)
output, err := cmd.CombinedOutput()
log.Println(string(output), err)
}