stalwartlabs / mail-server

Secure & Modern All-in-One Mail Server (IMAP, JMAP, POP3, SMTP)
https://stalw.art
3.55k stars 135 forks source link

[enhancement]: use error code 550 on reject/ereject-Action (Sieve script) #446

Closed infrequently closed 1 month ago

infrequently commented 1 month ago

Which feature or improvement would you like to request?

I'd like to see this feature:

I use a Sieve script to block sending E-Mails to some addresses as discussed here. The "reject" and "ereject"-Actions are working and the mail-server rejects the message on protocol level as follows: [...] smtp::inbound::session: event="write" data="503 5.5.3 my reject message\r\n"[...]

As far as I understand RFC 5429 the error should be a 550 error.

2.1.1. Rejecting a Message at the SMTP/LMTP Protocol Level

Sieve implementations that are able to reject messages at the SMTP/ LMTP level MUST do so and SHOULD use the 550 response code.

[...]

If the SMTP/LMTP server supports RFC 2034 [ENHANCED-CODES], it MUST prepend an appropriate Enhanced Error Code to the "reason" text. Enhanced Error code 5.7.1 or a more generic 5.7.0 are RECOMMENDED.

I suggest changing the error code accordingly.

PS: Using Stalwart 0.7.3, update to 0.8.0 pending

Is your feature request related to a problem?

I'm having a problem with...

Code of Conduct

mdecimus commented 1 month ago

You can include the status code in the reject action, for instance:

reject "551 5.1.1 Your domain '${env.helo_domain}' has been blocklisted.";

There is an example in the repository under tests/resources/smtp/sieve/stage_ehlo.sieve.