fix fields not exported in json

This commit is contained in:
shoopea 2022-06-19 12:33:24 +08:00
parent 55d1c2330d
commit fcc9fa3f5c
3 changed files with 8 additions and 8 deletions

View File

@ -36,7 +36,7 @@ func main() {
}
if *testMailFlag {
SendMail(cfg.Email.smtpHost, cfg.Email.fromEmail, "test backup email topic", "test backup email body", cfg.Email.toEmail)
SendMail(cfg.Email.SmtpHost, cfg.Email.FromEmail, "test backup email topic", "test backup email body", cfg.Email.ToEmail)
os.Exit(0)
}
@ -47,7 +47,7 @@ func main() {
}
if len(email.items) > 0 {
SendMail(cfg.Email.smtpHost, cfg.Email.fromEmail, "Autobackup report", fmt.Sprintf("%v", email.items), cfg.Email.toEmail)
SendMail(cfg.Email.SmtpHost, cfg.Email.FromEmail, "Autobackup report", fmt.Sprintf("%v", email.items), cfg.Email.ToEmail)
log.Printf("Sending summary email\r\n%v", email.items)
}
}

View File

@ -54,21 +54,21 @@ func (c *Config) Load() error {
return err
}
if len(cfg.Email.smtpHost) == 0 {
if len(cfg.Email.SmtpHost) == 0 {
if *debugFlag {
log.Printf("Config.Load : no smtp")
}
return fmt.Errorf("no smtp")
}
if len(cfg.Email.fromEmail) == 0 {
if len(cfg.Email.FromEmail) == 0 {
if *debugFlag {
log.Printf("Config.Load : no email from")
}
return fmt.Errorf("no email from")
}
if len(cfg.Email.toEmail) == 0 {
if len(cfg.Email.ToEmail) == 0 {
if *debugFlag {
log.Printf("Config.Load : no email to")
}

View File

@ -14,9 +14,9 @@ type Email struct {
}
type EmailConfig struct {
smtpHost string `json:"smtp"`
fromEmail string `json:"email_from"`
toEmail []string `json:"email_to"`
SmtpHost string `json:"smtp"`
FromEmail string `json:"email_from"`
ToEmail []string `json:"email_to"`
}
func SendMail(addr, from, subject, body string, to []string) error {