This is something I wanted to add during the previous vdelivermail rewrite, but didn't get around to.
On catchall messages, insert two Delivered-To headers. One for the envelope recipient, and one for the catchall mailbox.
For example:
Delivered-To: catchall@domain.com
Delivered-To: johndoe@domain.com
Isn't multiple Delivered-To headers breaking the idea of what Delivered-To means? Delivered-To generally
means final delivery, doesn't it?
I'm not sure about that... I found this from the Postfix manual, and it seems to imply that there could be multiple Delivered-To headers, and that they might be used for loop detection.
MAIL FORWARDING
For the sake of reliability, forwarded mail is re-submit-
ted as a new message, so that each recipient has a sepa-
rate on-file delivery status record.
In order to stop mail forwarding loops early, the software
adds an optional Delivered-To: header with the final enve-
lope recipient address. If mail arrives for a recipient
that is already listed in a Delivered-To: header, the mes-
sage is bounced.
Yeah, makes sense, but I've seen some server-side mail handlers that have issues handling zero, or multiple Delivered-To headers. I guess that's their problem though.
Actually, I don't think it should say catchall@. It should use the envelope address probably. If there's indeed a
catchall, then the original address should be treated as if it exists. Thoughts?
Say you have sales@example.com forward to john@example.com. I'd like to see the Delivered-To headers act like Received headers. Maybe john@example.com forwards to jdoe@example.net. In that case:
Delivered-To: jdoe@example.net
Received: [standard Received header here]
Received: [another Received header]
Delivered-To: john@example.com
Delivered-To: sales@example.com
Received: [received headers from sender to example.com]
One benefit of this setup, is that vdelivermail could look at all headers before inserting the Delivered-To. If there's already a Delivered-To that matches the one it is about to insert, the mail is looping.