more debug

This commit is contained in:
shoopea 2022-06-19 12:18:34 +08:00
parent db052048b6
commit f3abe27055
2 changed files with 32 additions and 5 deletions

View File

@ -27,21 +27,36 @@ func SendMail(addr, from, subject, body string, to []string) error {
c, err := smtp.Dial(addr) c, err := smtp.Dial(addr)
if err != nil { if err != nil {
if *debugFlag {
log.Printf("SendMail : smtp.Dial (%s)", err)
}
return err return err
} }
defer c.Close() defer c.Close()
if err = c.Mail(r.Replace(from)); err != nil { if err = c.Mail(r.Replace(from)); err != nil {
if *debugFlag {
log.Printf("SendMail : client.Mail (%s)", err)
}
return err return err
} }
for i := range to { for i := range to {
to[i] = r.Replace(to[i]) to[i] = r.Replace(to[i])
if err = c.Rcpt(to[i]); err != nil { if err = c.Rcpt(to[i]); err != nil {
if *debugFlag {
log.Printf("SendMail : client.Rcpt (%s)", err)
}
return err return err
} }
} }
w, err := c.Data() w, err := c.Data()
if err != nil { if err != nil {
if *debugFlag {
log.Printf("SendMail : client.Data (%s)", err)
}
return err return err
} }
@ -58,11 +73,23 @@ func SendMail(addr, from, subject, body string, to []string) error {
_, err = w.Write([]byte(msg)) _, err = w.Write([]byte(msg))
if err != nil { if err != nil {
if *debugFlag {
log.Printf("SendMail : writer.Write (%s)", err)
}
return err return err
} }
err = w.Close() err = w.Close()
if err != nil { if err != nil {
if *debugFlag {
log.Printf("SendMail : writer.Close (%s)", err)
}
return err return err
} }
return c.Quit()
err = c.Quit()
if *debugFlag {
log.Printf("SendMail : client.Quit (%s)", err)
}
return err
} }

View File

@ -1,6 +1,6 @@
// Code generated by version.sh (@generated) DO NOT EDIT. // Code generated by version.sh (@generated) DO NOT EDIT.
package main package main
var githash = "4937155" var githash = "db05204"
var buildstamp = "2022-06-19_04:13:42" var buildstamp = "2022-06-19_04:18:29"
var commits = "44" var commits = "45"
var version = "4937155-b44 - 2022-06-19_04:13:42" var version = "db05204-b45 - 2022-06-19_04:18:29"