satellite/email: Add support for unauthenticated, cleartext SMTP connections

Change-Id: I11b4852122764c1ede188ca40d5edb14f2c4ee72
This commit is contained in:
Ethan Adams 2023-09-25 17:04:53 -05:00 committed by Storj Robot
parent 02899dfae2
commit 6961d2e19d
2 changed files with 17 additions and 10 deletions

View File

@ -55,18 +55,20 @@ func (sender *SMTPSender) communicate(ctx context.Context, client *smtp.Client,
// before creating SMTPSender
host, _, _ := net.SplitHostPort(sender.ServerAddress)
// send smtp hello or ehlo msg and establish connection over tls
err := client.StartTLS(&tls.Config{ServerName: host})
if err != nil {
return err
if sender.Auth != nil {
// send smtp hello or ehlo msg and establish connection over tls
err := client.StartTLS(&tls.Config{ServerName: host})
if err != nil {
return err
}
err = client.Auth(sender.Auth)
if err != nil {
return err
}
}
err = client.Auth(sender.Auth)
if err != nil {
return err
}
err = client.Mail(sender.From.Address)
err := client.Mail(sender.From.Address)
if err != nil {
return err
}

View File

@ -276,6 +276,11 @@ func setupMailService(log *zap.Logger, config Config) (*mailservice.Service, err
},
ServerAddress: mailConfig.SMTPServerAddress,
}
case "insecure":
sender = &post.SMTPSender{
From: *from,
ServerAddress: mailConfig.SMTPServerAddress,
}
case "nomail":
sender = simulate.NoMail{}
default: