update http

This commit is contained in:
shoopea
2023-08-20 16:57:53 +02:00
parent b07a74543b
commit 1a1713eb14
53 changed files with 59127 additions and 75 deletions

View File

@@ -19,6 +19,7 @@ type Email struct {
}
type EmailConfig struct {
Active bool `json:"active"`
SmtpHost string `json:"smtp"`
FromEmail string `json:"email_from"`
ToEmail []string `json:"email_to"`
@@ -38,7 +39,7 @@ func (e *Email) AddItem(item string) {
e.items = append(e.items, item)
}
func (e *Email) Send() error {
func (e *Email) Send(addr, from string, to []string) error {
log.WithFields(log.Fields{}).Debugf("starting")
defer log.WithFields(log.Fields{}).Debugf("done")
@@ -57,8 +58,8 @@ func (e *Email) Send() error {
subject := fmt.Sprintf("Autobackup report (%s)", e.startTime)
if err := SendMail(cfg.Email.SmtpHost, cfg.Email.FromEmail, subject, body, cfg.Email.ToEmail); err != nil {
log.WithFields(log.Fields{"addr": cfg.Email.SmtpHost, "from": cfg.Email.FromEmail, "subject": subject, "call": "SendMail", "error": err}).Errorf("")
if err := SendMail(addr, from, subject, body, to); err != nil {
log.WithFields(log.Fields{"addr": addr, "from": from, "subject": subject, "call": "SendMail", "error": err}).Errorf("")
return err
}