Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(smtp): use param props from params arg #430

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions pkg/services/smtp/smtp.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (service *Service) Send(message string, params *types.Params) error {
return fail(FailApplySendParams, err)
}

client, err := getClientConnection(service.config)
client, err := getClientConnection(&config)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

	if useImplicitTLS(config.Encryption, config.Port) {
		conn, err = tls.Dial("tcp", addr, &tls.Config{
			ServerName: config.Host,
		})
	} else {
		conn, err = net.Dial("tcp", addr)
	}

This was ignoring the value in the params var

if err != nil {
return fail(FailGetSMTPClient, err)
}
Expand Down Expand Up @@ -206,7 +206,7 @@ func (service *Service) sendToRecipient(client *smtp.Client, toAddress string, c
return fail(FailOpenDataStream, err)
}

if err := writeHeaders(wc, service.getHeaders(toAddress, config.Subject)); err != nil {
if err := writeHeaders(wc, service.getHeaders(toAddress, config)); err != nil {
return err
}

Expand All @@ -228,9 +228,7 @@ func (service *Service) sendToRecipient(client *smtp.Client, toAddress string, c
return nil
}

func (service *Service) getHeaders(toAddress string, subject string) map[string]string {
conf := service.config

func (service *Service) getHeaders(toAddress string, conf *Config) map[string]string {
var contentType string
if conf.UseHTML {
contentType = fmt.Sprintf(contentMultipart, service.multipartBoundary)
Expand All @@ -239,7 +237,7 @@ func (service *Service) getHeaders(toAddress string, subject string) map[string]
}

return map[string]string{
"Subject": subject,
"Subject": conf.Subject,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

conf.Subject may contain changes from the var

"Date": time.Now().Format(time.RFC1123Z),
"To": toAddress,
"From": fmt.Sprintf("%s <%s>", conf.FromName, conf.FromAddress),
Expand Down
Loading