Nilhcem/FakeSMTP

Error generation

Opened this issue · 2 comments

A vital part of testing SMTP clients is in error handling. FakeSMTP is great for testing success, but it would be really useful to be able to deliberately provoke specific standard RFC821 and extended RFC3463 error responses, perhaps via special addresses, for example:

421@error.example.com => 421 4.2.1 Delivery deferred. Please try later
422@error.example.com => 422 4.2.2 Mailbox full
511@error.example.com => 550 5.1.1 Unknown User
571@error.example.com => 550 5.7.1 Rejected by spam filter
user@551.example.com => 551 5.5.1 Relaying denied (applies to whole domain, not just user)

Postfix's smtp-sink project does this to an extent, but it doesn't have the nice usability that FakeSMTP does. There's a good doc on SMTP errors here.

I think this will largely involve extending MailListener->accept, but I'm not a Java coder...

Another thought - it would be good to be able to test timeouts too, perhaps with delay10@error.example.com, though there would probably need to be an app-level delay option to support greetdelay, which needs to occur before HELO.

Thanks for the issue, it could indeed be a really nice improvement.

I will check if this can be implemented easily, otherwise we will probably need to wait for a pull request on this one.