Browse Source

Fix error, run SMTP, log sql update error

Vova Tkach 5 years ago
parent
commit
bd4617b0a7
2 changed files with 7 additions and 1 deletions
  1. 4 0
      main.go
  2. 3 1
      smtp.go

+ 4 - 0
main.go

@@ -106,6 +106,10 @@ func main() {
 	xml_cl_ch, xml_cl_stop := xml_start(consts.ParamWwwDir, mpool)
 	defer xml_stop(xml_cl_ch, xml_cl_stop)
 
+	// SMTP sender
+	smtp_cl_ch, smtp_cl_stop := smtp_start(consts.ParamWwwDir, mpool)
+	defer smtp_stop(smtp_cl_ch, smtp_cl_stop)
+
 	// Init cache blocks
 	cbs := cblocks.New()
 

+ 3 - 1
smtp.go

@@ -75,7 +75,7 @@ func smtp_prepare(db *sqlw.DB, conf *config.Config) {
 				if _, err := db.Exec(
 					`UPDATE notify_mail SET status = 3 WHERE id = ?;`,
 					utils.StrToInt(string(values[0])),
-				); err != nil {
+				); err == nil {
 					go func(db *sqlw.DB, conf *config.Config, id int, subject, msg string, receivers []string) {
 						if err := smtp_send(
 							(*conf).SMTP.Host,
@@ -109,6 +109,8 @@ func smtp_prepare(db *sqlw.DB, conf *config.Config) {
 						html.EscapeString(string(values[3])),
 						[]string{html.EscapeString(string(values[1]))},
 					)
+				} else {
+					fmt.Printf("Smtp send error (sql, update): %v\n", err)
 				}
 			}
 		}