diff --git a/README.md b/README.md index d437684..403dcb5 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,7 @@ smtp: smtp_cc: - to@email.com smtp_format: "{{data}}" + subject: "Email subject" custom: - id: webhook diff --git a/pkg/providers/smtp/smtp.go b/pkg/providers/smtp/smtp.go index 4b68ea8..72b1870 100644 --- a/pkg/providers/smtp/smtp.go +++ b/pkg/providers/smtp/smtp.go @@ -23,6 +23,7 @@ type Options struct { FromAddress string `yaml:"from_address,omitempty"` SMTPCC []string `yaml:"smtp_cc,omitempty"` SMTPFormat string `yaml:"smtp_format,omitempty"` + Subject string `yaml:"subject,omitempty"` } func New(options []*Options, ids []string) (*Provider, error) { @@ -42,7 +43,7 @@ func (p *Provider) Send(message, CliFormat string) error { for _, pr := range p.SMTP { msg := utils.FormatMessage(message, utils.SelectFormat(CliFormat, pr.SMTPFormat)) - url := fmt.Sprintf("smtp://%s:%s@%s/?fromAddress=%s&toAddresses=%s", pr.Username, pr.Password, pr.Server, pr.FromAddress, strings.Join(pr.SMTPCC, ",")) + url := fmt.Sprintf("smtp://%s:%s@%s/?fromAddress=%s&toAddresses=%s&subject=%s", pr.Username, pr.Password, pr.Server, pr.FromAddress, strings.Join(pr.SMTPCC, ","),pr.Subject) err := shoutrrr.Send(url, msg) if err != nil { err = errors.Wrap(err, fmt.Sprintf("failed to send smtp notification for id: %s ", pr.ID))