Idea: add %user% and %domain% to new recipients?

Julian Field MailScanner at
Sun Apr 13 14:07:14 IST 2008

How about in the Spam Actions or other places when a recipient is added 
to the list of recipients for a message, you could specify _USER_ and 
_DOMAIN_, and substitute those into the new address?

As an example, this would quickly give you a sorted spam archive:
Archive Mail = spam-archive-_USER__at__DOMAIN_ at
This would auto-forward a message addressed to foobar at to at
Archive Mail = /var/spool/MailScanner/archive/_DOMAIN_
Spam Actions = spam-archive-_USER__at__DOMAIN_ at
where your mailertable (or your MTA's equivalent) delivers 
* to a database server that delivers 
spam-archive-* using procmail into a database 
that presents a web page to the user for them to be able to retrieve 
their spam.

Obviously, with a message with multiple recipients, it would have to add 
multiple corresponding recipients to the message. So the "Mail Archive 
=" example above would add 3 new recipients to a message that originally 
had 3 recipients.

Sound useful?

The only extra thing that might need implementing is a "mkdir -p" 
function, and there is a problem that the current spec says that if the 
"Archive Mail" destination does not exist, it is treated as a directory 
containing message files. If it's a file that does exist, then it's easy 
as that is an mbox file. So I might need a new config option along the 
lines of "Automatically Create Mail Archive As = " followed by "file" or 
"mbox" or "dir" or "directory", as you might want to auto-create them as 
mbox files. Currently this decision is not a problem as the directory 
can only contain a fixed string or the date, which is predictable and so 
can be created in advance by a cron job.
What would I do for the same problem occurring in "Spam Actions" and its 
relations? Again, we end up with an unpredictable name. I don't *think* 
it's a problem this time as it can only be a directory, but I would 
still have to create the directory structure if it doesn't exist. Please 
let me know if I'm wrong.

It should be fairly easy to implement, and might prove to be very useful 
for big sites or those with complex setups. Should remove the need for 
Custom Functions in quite a few situations. And it *doesn't* add any 
more MailScanner.conf settings, just adds more flexibility to those that 
are already there, which is always a good thing :-)

What else have I missed here?

What do you think?
Useful to you?

Please let me know if you think you might find it useful, and what you 
think of the idea.


Julian Field MEng CITP CEng
Buy the MailScanner book at

MailScanner customisation, or any advanced system administration help?
Contact me at Jules at Jules.FM

PGP footprint: EE81 D763 3DB0 0BFD E1DC 7222 11F6 5947 1415 B654
PGP public key:

This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

More information about the MailScanner mailing list