foxcpp / maddy

✉️ Composable all-in-one mail server.
https://maddy.email
GNU General Public License v3.0
5.1k stars 246 forks source link

"Deferred" status DSNs #326

Open foxcpp opened 3 years ago

foxcpp commented 3 years ago

However, e-mails have gone missing since the 10th of December and I only just found out the hard way last night (13th January), that this has been going on.

I believe security policy errors currently defer delivery instead of failing it with a permanent error (and thus notifying you immediately). With default configuration it means messages get stuck in the queue for up to 5 days before actually giving up even if it is hopeless. The reason for this behavior is potential intermittent nature of various delivery failures. Sorry for your experience.

Do you think implementing a notification saying that the message is not delivered is a good solution to this?

Originally posted by @foxcpp in https://github.com/foxcpp/maddy/issues/301#issuecomment-760409433

reivilibre commented 3 years ago

I personally think that's a good idea. Self-hosting e-mails is fraught with stupid blacklists that will blacklist you for no apparent reason. If we're not told that something is going on, we might not find out about it.

How does postfix handle this? I feel like I've seen a message/DSN before that it 'failed but will keep retrying'.

I don't think doing this would be unusual or at least not unexpected?

However, I have another issue (going to open a new one) in that I don't seem to be receiving any DSNs at all, even for permanent errors or even after the 5 day retry queue (I didn't change any of that, to my knowledge, and yet I still had e-mails vanish for a month and still not told about them — found out because the other person was confused as to why I had stopped replying to them :sweat_smile:)

foxcpp commented 3 years ago

How does postfix handle this? I feel like I've seen a message/DSN before that it 'failed but will keep retrying'.

I believe default postfix behavior is to keep trying silently but it is definitely possible for a client to explicitly request such DSN using SMTP DSN extension postfix implements.

foxcpp commented 3 years ago

It may be reasonable idea to send such notification only when 2 attempt fails since many small-scale servers implement greylisting so first attempt will almost always fail.

foxcpp commented 3 years ago

If someone wants to jump in and implement it before I get a chance:

  1. Improve human-readable message formatting to mention "will keep trying" if status is Delayed: https://github.com/foxcpp/maddy/blob/fe973563958f382411074a38b44fb5dc1fe80503/internal/dsn/dsn.go#L292
  2. Refactor q.emitDSN to allow generating "deferred" DSNs: https://github.com/foxcpp/maddy/blob/fe973563958f382411074a38b44fb5dc1fe80503/internal/target/queue/queue.go#L875
  3. Call q.emitDSN somewhere here: https://github.com/foxcpp/maddy/blob/fe973563958f382411074a38b44fb5dc1fe80503/internal/target/queue/queue.go#L445