Automatic procmail filter based on username

大憨熊 提交于 2021-01-29 12:47:56

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!