diff --git a/internal/services/smtp/smtp.go b/internal/services/smtp/smtp.go index 6f551e32..73d14e95 100644 --- a/internal/services/smtp/smtp.go +++ b/internal/services/smtp/smtp.go @@ -102,7 +102,7 @@ func (s *Service) smtpSendMail(ctx context.Context, authID string, from string, } } - if !fromAddr.Send { + if !fromAddr.Send || fromAddr.Status != proton.AddressStatusEnabled { s.log.Errorf("Can't send emails on address: %v", fromAddr.Email) return &ErrCanNotSendOnAddress{address: fromAddr.Email} } diff --git a/tests/features/smtp/send/failures.feature b/tests/features/smtp/send/failures.feature index 19c53538..0adc0ac1 100644 --- a/tests/features/smtp/send/failures.feature +++ b/tests/features/smtp/send/failures.feature @@ -1,6 +1,7 @@ Feature: SMTP wrong messages Background: Given there exists an account with username "[user:user]" and password "password" + And the account "[user:user]" has additional disabled address "[user:disabled]@[domain]" And there exists an account with username "[user:to]" and password "password" Then it succeeds When bridge starts @@ -54,4 +55,14 @@ Feature: SMTP wrong messages hello """ - Then it fails + Then it fails with error "invalid return path" + + Scenario: Send from a valid address that cannot send + When SMTP client "1" sends the following message from "[user:disabled]@[domain]" to "[user:to]@[domain]": + """ + From: Bridge Test Disabled <[user:disabled]@[domain]> + To: Internal Bridge <[user:to]@[domain]> + + Hello + """ + And it fails with error "Error: can't send on address: [user:disabled]@[domain]"