完善
This commit is contained in:
parent
5a4d808f89
commit
395280a363
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -2,4 +2,6 @@
|
||||||
.gitignore
|
.gitignore
|
||||||
rss.iml
|
rss.iml
|
||||||
rss
|
rss
|
||||||
fetchdapenti
|
fetchdapenti
|
||||||
|
/run.sh
|
||||||
|
/sendmail
|
|
@ -88,6 +88,10 @@ func fetch(u string) (r rss2.Item) {
|
||||||
var hadSend = safety.NewMap[string, struct{}]()
|
var hadSend = safety.NewMap[string, struct{}]()
|
||||||
|
|
||||||
func downAndSendMail(doc *goquery.Document, title string) {
|
func downAndSendMail(doc *goquery.Document, title string) {
|
||||||
|
if err := mail.CheckEnv(); err != nil {
|
||||||
|
log.Println("err", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
type m struct {
|
type m struct {
|
||||||
tit string
|
tit string
|
||||||
content string
|
content string
|
||||||
|
|
16
mail/mail.go
16
mail/mail.go
|
@ -7,23 +7,29 @@ import (
|
||||||
"os/exec"
|
"os/exec"
|
||||||
)
|
)
|
||||||
|
|
||||||
func SendMail(subject string, content string, files ...string) error {
|
var cm, subjectParam, contentParam, fileParam string
|
||||||
cm := os.Getenv("mail_cmd_path")
|
|
||||||
|
func CheckEnv() error {
|
||||||
|
cm = os.Getenv("mail_cmd_path")
|
||||||
if cm == "" {
|
if cm == "" {
|
||||||
return errors.New("cmd can't empty")
|
return errors.New("cmd can't empty")
|
||||||
}
|
}
|
||||||
subjectParam := os.Getenv("mail_cmd_subject_param_name")
|
subjectParam = os.Getenv("mail_cmd_subject_param_name")
|
||||||
if subjectParam == "" {
|
if subjectParam == "" {
|
||||||
return errors.New("title param name empty")
|
return errors.New("title param name empty")
|
||||||
}
|
}
|
||||||
contentParam := os.Getenv("mail_cmd_content_param_name")
|
contentParam = os.Getenv("mail_cmd_content_param_name")
|
||||||
if contentParam == "" {
|
if contentParam == "" {
|
||||||
return errors.New("content param name emtpy")
|
return errors.New("content param name emtpy")
|
||||||
}
|
}
|
||||||
fileParam := os.Getenv("mail_cmd_file_param_name")
|
fileParam = os.Getenv("mail_cmd_file_param_name")
|
||||||
if fileParam == "" {
|
if fileParam == "" {
|
||||||
return errors.New("file empty")
|
return errors.New("file empty")
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SendMail(subject string, content string, files ...string) error {
|
||||||
v := []string{subjectParam, subject, contentParam, content}
|
v := []string{subjectParam, subject, contentParam, content}
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
if f != "" {
|
if f != "" {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user