fix(GODT-2617): Validate user can send from the SMTP sender address

https://github.com/ProtonMail/go-proton-api/pull/126
This commit is contained in:
Leander Beernaert
2023-11-15 14:11:28 +01:00
parent 1cafbfcaaa
commit ea1c2534df
5 changed files with 79 additions and 5 deletions

View File

@ -97,11 +97,16 @@ func (s *Service) smtpSendMail(ctx context.Context, authID string, from string,
from = sender
fromAddr, err = s.identityState.GetAddr(from)
if err != nil {
logrus.WithError(err).Errorf("Failed to get identity from sender address %v", sender)
logrus.WithError(err).Errorf("Failed to get identity for from address %v", sender)
return ErrInvalidReturnPath
}
}
if !fromAddr.Send {
s.log.Errorf("Can't send emails on address: %v", fromAddr.Email)
return &ErrCanNotSendOnAddress{address: fromAddr.Email}
}
// Load the user's mail settings.
settings, err := s.client.GetMailSettings(ctx)
if err != nil {