Skip to content

Commit

Permalink
Add subject customization #118 (#141)
Browse files Browse the repository at this point in the history
* go.mod update to 1.17 and dependency synchronisation

* Docker file update to use go 1.18 and "go install" instead of "go get"

* Minor documentation updates

* GitHub action version updates

* goreleaser-action version fix

* Add subject customization #118

Co-authored-by: Sandeep Singh <sandeep@projectdiscovery.io>
Co-authored-by: forgedhallpass <13679401+forgedhallpass@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 11, 2022
1 parent 0f09512 commit 2675583
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ smtp:
smtp_cc:
- to@email.com
smtp_format: "{{data}}"
subject: "Email subject"

custom:
- id: webhook
Expand Down
3 changes: 2 additions & 1 deletion pkg/providers/smtp/smtp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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))
Expand Down

0 comments on commit 2675583

Please sign in to comment.