问题
I use postfix and procmail for mail and folder filtering. I have a main address and a bunch of alias addresses that go to it, then I sort the username to a folder that matches. For example I have the main address of 'address@domain.com" and a alias of "customer1@domain.com" pointing to it, and I have a folder called 'customer1' under 'address@domain.com' and a script like the following in .procmailrc -
:0:
* ^(To|Cc).*customer1@domain.com
.customer1/
and it works fine, but every time I add a alias I have to also add a line in .procmailrc to filter to it. Would there be a way I can create the alias, the folder, and have one procmail recipe that would grab the 'customer1' from the address and store the message in a folder by that same name? Even having procmail create the folder if it does not exist would be great too. Thanks!
回答1:
Ok I found another question that was similar that solved this, Procmail to automatically make new folders to store emails from new senders
So the following code solved the quesiton -
Who=`formail -zxTo: | cut -d@ -f1`
:0
* ? mkdir -p ".$Who"
.$Who/
I tested it and it worked wonderfully
来源:https://stackoverflow.com/questions/52408573/automatic-procmail-filter-based-on-username