update http
This commit is contained in:
7
email.go
7
email.go
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user