简体   繁体   English

如何使用procmail以base 64编码过滤电子邮件

[英]How to filter email with base 64 encoding using procmail

I am trying to filter email with base 64 encoding, then decode the message body, then pass it for further filtering, but it won't find a match on the type of email from header, I tried Content-Transfer-Encoding and Content-Type, but no match are found from the header. 我正在尝试使用base 64编码过滤电子邮件,然后解码邮件正文,然后将其传递以进行进一步过滤,但是找不到与邮件头中的电子邮件类型匹配的内容,我尝试了Content-Transfer-Encoding和Content-类型,但从标题中找不到匹配项。 Here is the procmailrc I configured: 这是我配置的procmailrc:

DEFAULT=/var/mail/
LOGFILE=$HOME/procmail.log
SHELL=/bin/sh
msgID=""
errorMSG="Error."

:0
* (r|R)@domain.com

:0fw
* ^Content-Transfer-Encoding:.*base64 | mmencode -u -b

{
:0B
* ^()\/[a-z]+[0-9]+
{ msgID = "$MATCH" }

result=`mysql -uxxx -pxxx -e "select data from table1 where id='"$msgID"'`

.... ....

The | mmencode -u -b | mmencode -u -b | mmencode -u -b is in the wrong place. | mmencode -u -b放在错误的位置。 You have made it part of the regex you are trying to match -- of course it won't. 您已将它作为要匹配的正则表达式的一部分-当然不会。

You probably mean 你可能是说

:0fw
* r@domain\.com
* ^Content-Transfer-Encoding:.*base64
| mmencode -u -b

or possibly 或可能

:0
* r@domain\.com
{
    :0fw
    * ^Content-Transfer-Encoding:.*base64
    | mmencode -u -b
#...
}

The general form of a Procmail recipe is Procmail配方的一般形式是

:0flags
* conditions
action

where you can omit the conditions to make a recipe unconditional; 您可以省略条件以使配方无条件; but the action is mandatory. 但是该操作是强制性的。 You cannot leave it out. 您不能忽略它。

If you change the content encoding, you should also update the corresponding MIME headers (unless you are ditching this message once you are done with it, of course). 如果更改了内容编码,则还应该更新相应的MIME标头(当然,除非您在处理完此消息后就放弃了此消息)。

Notice also how the (r|R) alternation is unnecessary, because Procmail matches case-insensitively by default. 还请注意,不需要(r|R)交替,因为Procmail默认情况下不区分大小写地匹配。

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

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