37 lines
698 B
Go
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)
|
||
|
}
|