简体   繁体   English

Procmail 规则更改主题并转发副本

[英]Procmail rule to change subject and forward a copy

I have an existing procmail recipe to forward a copy to my gmail account that is working well:我有一个现有的 procmail 配方,可以将副本转发到运行良好的 gmail 帐户:

:0c
! myAddress@gmail.com

I have a second rule that is also working well (in limited testing) to prefix the subject with [OLD DOMAIN]:我有第二条规则也很好用(在有限的测试中),用 [OLD DOMAIN] 为主题添加前缀:

:0fwh
* (To|Cc).*oldDomain.com
* ^Subject:\/.+
| formail -I"Subject: [OLD DOMAIN]$MATCH"  

The issue is in my local email account I get the modified subject as expected, but not in my gmail account.问题出在我的本地 email 帐户中,我按预期获得了修改后的主题,但不在我的 gmail 帐户中。 How can I combine these rules or modify the forward and copy rule to change the subject?如何组合这些规则或修改转发和复制规则以更改主题?

Just reverse their order;只需颠倒他们的顺序; make sure the one which rewrites the subject runs before the one which forwards a copy to Gmail.确保重写主题的那个在将副本转发到 Gmail 的那个之前运行。

Procmail simply processes your .procmailrc from top to bottom for each incoming message, and stops processing it once a (non-cloning) delivering action is successful. Procmail 只是为每条传入消息从上到下处理您的.procmailrc ,并在(非克隆)传递操作成功后停止处理它。 The c flag says to clone the message (so, even though the clone is successfully delivered, continue processing the original copy). c标志表示要克隆消息(因此,即使克隆已成功传递,仍继续处理原始副本)。

As an aside, the regex for (To|Cc) should probably have a ^ anchor in front, unless you specifically want to match the text anywhere in a header line.顺便说一句, (To|Cc)的正则表达式可能应该在前面有一个^锚,除非您特别想匹配 header 行中的任何地方的文本。

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

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