简体   繁体   English

如果有多个收件人使用procmail,则将电子邮件放在多个文件夹中

[英]Put email multiple folder in case of multiple recipients using procmail

I'm going to build an email system at home and I'm subscribed to a lot of mailing list. 我要在家中建立一个电子邮件系统,并且订阅了很多邮件列表。 The emails fetched to my local machine by fetchmail and filtered by procmail. 电子邮件通过fetchmail提取到我的本地计算机,并通过procmail过滤。 But, there is a situation which is not possible to solve with my current knowledge. 但是,用我目前的知识无法解决这种情况。 I have been googling for 2-3 hours to find a solution without any result. 我已经搜寻了2-3个小时,以找到没有任何结果的解决方案。

What I want is that, I get an email with multiple recipients and I would like to copy this email to different folders. 我想要的是,我收到一封包含多个收件人的电子邮件,并且希望将此电子邮件复制到其他文件夹中。 Here is an example: 这是一个例子:

Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org

I would like to put this email into linux-kernel and linux-kernel-janitors folder. 我想将此电子邮件放入linux-kernel和linux-kernel-janitors文件夹。 How can I do it by procmail? 如何通过procmail做到这一点?

Thanks in advance! 提前致谢!

You can make Procmail loop on the list of recipients by using SWITCHRC= but this is rather hackish. 您可以使用SWITCHRC=在收件人列表上使Procmail循环播放,但这SWITCHRC= Or, if you have a limited list of folders you want to process, you can deliver into each separately, and drop the message if you have delivered it at least once. 或者,如果要处理的文件夹列表有限,则可以将它们分别传递到每个文件夹中,如果已传递至少一次,则将其删除。

LASTFOLDER=
:0c:
* ^TO_linux-kernel@vger\.kernel\.org\>
linux-kernel
:0c:
* ^TO_kernel-janitors@vger\.kernel\.org\>
kernel-janitors
# ... repeat for other addresses you want to multiplex ...
# If it was delivered, LASTFOLDER will be set
:0
* LASTFOLDER ?? .
/dev/null

If you may have copied into additional inboxes before reaching this section, you want to explicitly set LASTFOLDER to the empty string. 如果您在到达本节之前可能已复制到其他收件箱,则需要将LASTFOLDER显式设置为空字符串。 It should not be necessary otherwise, but I left it in as a precaution. 否则就没有必要了,但我还是留作预防。 (This variable contains the name of the latest folder the message was delivered to.) (此变量包含邮件发送到的最新文件夹的名称。)

The solution looks like this: 解决方案如下所示:

First of all, an If statement is needed because my .procmailrc file contains not just kernel mailing list filter conditions. 首先,需要一个If语句,因为我的.procmailrc文件不仅包含内核邮件列表过滤条件。 If it matches than there is another list of conditions. 如果匹配,则存在另一个条件列表。 I think by the time it will be more fine-grained. 我认为到那时它将变得更细。

:0
 * [To|Cc].*vger.kernel.org
   LASTFOLDER=

    :0Ac:
    * ^[To|Cc].*linux-janitors@vger.kernel.org
    | DoItSomethingWithIt

    :0Ac:
    * ^[To|Cc].*linux-kernel@vger.kernel.org
    | DoItSomethingWithIt2

    :0                             
    * LASTFOLDER ?? .
    | DoItSomethingWithIt3

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM