简体   繁体   English

procmail:调节多个字段

[英]procmail: conditioning on multiple fields

I would like to store e-mails sent by me to others using the "From" field to a folder called "/sent"我想将我使用“发件人”字段发送给其他人的电子邮件存储到名为“/sent”的文件夹中

So, I use:所以,我使用:

:0:
*^From.*user@outlook.com
$HOME/Mail/sent/.

And it used to work fine.它曾经工作得很好。 However, now I am also forwarding my e-mail from the address:user@outlook.com, what is happending is that the e-mail envelope contains the header: Resent-From.*user@outlook.com so all forwarded e-mail is being saved to the sent folder.但是,现在我也从地址转发我的电子邮件:user@outlook.com,发生的事情是电子邮件信封包含标题:Resent-From.*user@outlook.com 所以所有转发的电子邮件邮件正在保存到已发送文件夹。

Is it possible to have a double condition.是否可以有双重条件。 That is something that says that if both Resent-From and From have *user@outlook.com, then it should go to the sent-folder.这就是说,如果 Resent-From 和 From 都有 *user@outlook.com,那么它应该转到发送文件夹。 In other words, is it possible to use a AND or OR or Negation condition.换句话说,是否可以使用 AND 或 OR 或否定条件。

Update: The provided solution is correct.更新:提供的解决方案是正确的。 I was making an error in that I had neglected the ":".我犯了一个错误,因为我忽略了“:”。 Thanks for both the solution and the patience.感谢您的解决方案和耐心。 I also learnt a number of things and about a number of resources, for which also I am grateful,我还学到了很多东西和很多资源,对此我也很感激,

Thanks!谢谢!

Procmail by default does exactly what you ask.默认情况下,Procmail 完全按照您的要求执行。 Multiple conditions will be ANDed together.多个条件将一起进行 AND 运算。 The first one which fails causes the recipe to be abandoned;第一个失败导致配方被放弃; if they all succeed, the action is taken.如果他们都成功,则采取行动。

:0  # second colon removed - don't use lock on directories
* ^From:(.*\<)?user@outlook\.com
* ^Resent-From:(.*\<)?user@outlook\.com
$HOME/Mail/sent/.

Notice also how I modified your regex to tighten it up.还要注意我是如何修改你的正则表达式来收紧它的。

To do NOT, add a !不这样做,添加一个! in front of the condition.在条件面前。 To do OR, you can negate both conditions, and take the action in the "else" part (de Morgan's law).要执行 OR,您可以否定这两个条件,并在“其他”部分(德摩根定律)中执行操作。

:0
* ! First condition
* ! Other condition
{ } # do nothing
:0E # else, meaning at least one was true
action

Of course, if both conditions are regular expressions, you can simply use the regex or operator.当然,如果两个条件都是正则表达式,则可以简单地使用正则表达式或运算符。

:0
* First condition|Other condition
action

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

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