Apply all options to smtp session

This commit is contained in:
Gonne 2025-03-26 13:32:51 +01:00
parent a05407eba0
commit 6ef9395140
Signed by: Gonne
SSH key fingerprint: SHA256:J8w3ZCNyz9MoTLV+eU7YRTVw59NYig44i0IWhbsgQG8

View file

@ -165,12 +165,13 @@ func (r *RequestRepo) sendConfirmationMail(request models.Request) error {
message.SetBodyString(mail.TypeTextPlain, messageText.String())
var options []mail.Option
options = append(options, mail.WithPort(r.config.Mailer.SmtpPort))
if r.config.Mailer.SmtpUseAuth {
options = append(options, mail.WithSMTPAuth(mail.SMTPAuthPlain))
options = append(options, mail.WithUsername(r.config.Mailer.SmtpIdentity))
options = append(options, mail.WithPassword(r.config.Mailer.SmtpPassword))
}
client, err := mail.NewClient(r.config.Mailer.SmtpHost, mail.WithPort(r.config.Mailer.SmtpPort))
client, err := mail.NewClient(r.config.Mailer.SmtpHost, options...)
if err != nil {
log.Println(err.Error())
return err