add error when no authentication is configured

This commit is contained in:
Soner Sayakci 2022-03-04 17:03:04 +01:00
parent f15efcd6f2
commit ed6e51b4df
1 changed files with 5 additions and 0 deletions

View File

@ -49,6 +49,11 @@ func (s *SMTPSendingService) Send(mail *models.Mail) error {
if ok, _ := c.Extension("AUTH"); !ok {
return errors.New("smtp: server doesn't support AUTH")
}
if len(s.config.Username) == 0 || len(s.config.Password) == 0 {
return errors.New("smtp: server requires authentification, but no authentification is provided")
}
if err = c.Auth(s.auth); err != nil {
return err
}