feat(mail): don't try to authenticate when no username and password was provided

This commit is contained in:
kolaente 2022-08-03 13:41:42 +02:00
parent aed1ad6d96
commit d47edac376
Signed by untrusted user: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 4 additions and 1 deletions

View File

@ -48,7 +48,6 @@ func getClient() (*mail.Client, error) {
}
opts := []mail.Option{
mail.WithSMTPAuth(authType),
mail.WithPort(config.MailerPort.GetInt()),
mail.WithTLSPolicy(tlsPolicy),
//#nosec G402
@ -58,6 +57,10 @@ func getClient() (*mail.Client, error) {
}),
}
if config.MailerUsername.GetString() != "" && config.MailerPassword.GetString() != "" {
opts = append(opts, mail.WithSMTPAuth(authType))
}
if config.MailerUsername.GetString() != "" {
opts = append(opts, mail.WithUsername(config.MailerUsername.GetString()))
}