mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-17 14:37:02 +00:00
smtpsrv: Return a temporary error when we fail to check if a user exists
When we fail to check if a user exists, we currently return a permanent error, which can be misleading and also make things more difficult to troubleshoot. This patch makes chasquid return a temporary error in that case. Thanks to Thor77 (thor77@thor77.org) for suggesting this change.
This commit is contained in:
@@ -308,7 +308,7 @@ func TestTooManyRecipients(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRcptFailsExistsCheck(t *testing.T) {
|
||||
func TestRcptBrokenExists(t *testing.T) {
|
||||
c := mustDial(t, ModeSMTP, true)
|
||||
defer c.Close()
|
||||
|
||||
@@ -320,6 +320,24 @@ func TestRcptFailsExistsCheck(t *testing.T) {
|
||||
if err == nil {
|
||||
t.Errorf("Accepted RCPT with broken Exists")
|
||||
}
|
||||
expect := "451 4.4.3 Temporary error checking address"
|
||||
if err.Error() != expect {
|
||||
t.Errorf("RCPT returned unexpected error %q", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func TestRcptUserDoesNotExist(t *testing.T) {
|
||||
c := mustDial(t, ModeSMTP, true)
|
||||
defer c.Close()
|
||||
|
||||
if err := c.Mail("from@localhost"); err != nil {
|
||||
t.Fatalf("Mail: %v", err)
|
||||
}
|
||||
|
||||
err := c.Rcpt("doesnotexist@localhost")
|
||||
if err == nil {
|
||||
t.Errorf("Accepted RCPT for non-existent user")
|
||||
}
|
||||
expect := "550 5.1.1 Destination address is unknown (user does not exist)"
|
||||
if err.Error() != expect {
|
||||
t.Errorf("RCPT returned unexpected error %q", err.Error())
|
||||
|
||||
Reference in New Issue
Block a user