How do you determine the destination email address for catchall?

I have a catchall account setup and I have been receiving spam email that properly gets sorted into the junk folder as spam. However, I’d like to see which email address these were destined for so that I could set up a spam trap address instead. Whenever I look through any of the messages in the webui everything just says it’s delivered to [email protected] and not the address that it was originally intended for. Is there a way to see that?

Try the message headers? You could also try making your own milter for it.

Thanks for the response!

I have previously checked the message headers but since it is being sent as a BCC I can’t see the destination email address within the headers. The only thing I can see in the headers is a Delivered-To that points to the catchall address.

Similarly if I use the admin webui to locate the message it only ever shows it being delivered to the catchall address as well and not the intended destination.

I am unfamiliar with milter or how to utilize that to discover the destination.

Right, so, milters (mail filters) are basically little apps that can act as plugins for MTAs, they can examine and even change the e-mail as it flows through. You can make a script in NodeJS using milterjs (ignore my PR, stalwart doesn’t trigger that bug)

So in your case you can do something like milterjs.on("envrcpt", (ctx, rcpt) => { /* if rcpt[0] something something */}) to get the destination address, and reset the destination address to your catchall in the milter script. Then you configure stalwart to use your milter.

You could also do all your analysis in your milter and tell stalwart to drop the e-mail.