Browse Source

SendMail function

Vova Tkach 5 years ago
parent
commit
f2c83ce5ff
1 changed files with 21 additions and 0 deletions
  1. 21 0
      engine/wrapper/wrapper.go

+ 21 - 0
engine/wrapper/wrapper.go

@@ -281,6 +281,27 @@ func (this *Wrapper) ConfigSave() error {
 	return this.Config.ConfigWrite(this.DConfig + string(os.PathSeparator) + "config.json")
 	return this.Config.ConfigWrite(this.DConfig + string(os.PathSeparator) + "config.json")
 }
 }
 
 
+func (this *Wrapper) SendEmail(email, subject, message string) error {
+	if _, err := this.DB.Exec(
+		`INSERT INTO notify_mail SET
+			id = NULL,
+			email = ?,
+			subject = ?,
+			message = ?,
+			error = '',
+			datetime = ?,
+			status = 2
+		;`,
+		email,
+		subject,
+		message,
+		utils.UnixTimestampToMySqlDateTime(utils.GetCurrentUnixTimestamp()),
+	); err != nil {
+		return err
+	}
+	return nil
+}
+
 func (this *Wrapper) RecreateProductXmlFile() error {
 func (this *Wrapper) RecreateProductXmlFile() error {
 	trigger := strings.Join([]string{this.DTmp, "trigger.xml.run"}, string(os.PathSeparator))
 	trigger := strings.Join([]string{this.DTmp, "trigger.xml.run"}, string(os.PathSeparator))
 	if !utils.IsFileExists(trigger) {
 	if !utils.IsFileExists(trigger) {