test email
This commit is contained in:
parent
86ddd52642
commit
493715555d
@ -15,6 +15,7 @@ var (
|
||||
slowFlag = flag.Bool("slow", false, "slow process")
|
||||
testFlag = flag.Bool("test", false, "test run")
|
||||
debugFlag = flag.Bool("debug", false, "debug")
|
||||
testMailFlag = flag.Bool("test-mail", false, "test email setup")
|
||||
cfg Config
|
||||
email *Email
|
||||
)
|
||||
@ -34,6 +35,11 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if *testMailFlag {
|
||||
SendMail(cfg.Email.smtpHost, cfg.Email.fromEmail, "test backup email topic", "test backup email body", cfg.Email.toEmail)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
err = RunBackup(*appFlag)
|
||||
if err != nil {
|
||||
log.Printf("Cannot run schedule (%s)", err)
|
||||
|
5
email.go
5
email.go
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"log"
|
||||
"net/smtp"
|
||||
"strings"
|
||||
"time"
|
||||
@ -48,6 +49,10 @@ func SendMail(addr, from, subject, body string, to []string) error {
|
||||
"Content-Transfer-Encoding: base64\r\n" +
|
||||
"\r\n" + base64.StdEncoding.EncodeToString([]byte(body))
|
||||
|
||||
if *debugFlag {
|
||||
log.Printf("SendMail :\r\n%s", msg)
|
||||
}
|
||||
|
||||
_, err = w.Write([]byte(msg))
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by version.sh (@generated) DO NOT EDIT.
|
||||
package main
|
||||
var githash = "7c309b8"
|
||||
var buildstamp = "2022-06-19_03:58:59"
|
||||
var commits = "42"
|
||||
var version = "7c309b8-b42 - 2022-06-19_03:58:59"
|
||||
var githash = "86ddd52"
|
||||
var buildstamp = "2022-06-19_04:11:44"
|
||||
var commits = "43"
|
||||
var version = "86ddd52-b43 - 2022-06-19_04:11:44"
|
||||
|
Loading…
Reference in New Issue
Block a user