procmail给出"no match"在内容类型上 [英] procmail giving "no match" on content-type
问题描述
我正在尝试让procmail解码base64编码的附件.首先,我遵循一个简单的食谱,可以在这里找到:
I am trying to have procmail decode a base64 encoded attachment. To begin with I am following a simple recipe, found here:
However, it appears procmail cannot find the match:
procmail: [7459] Mon Aug 10 10:54:43 2015
procmail: Assigning "LOGFILE=/home/myself/procmail.log"
procmail: Opening "/home/myself/procmail.log"
procmail: Assigning "LOGABSTRACT=yes"
procmail: Assigning "LINEBUF=65535"
procmail: No match on "^Content-Type: *text/plain"
procmail: Locking "/home/myself/scratch/prc.out.lock"
procmail: Assigning "LASTFOLDER=/home/myself/scratch/prc.out"
procmail: Opening "/home/myself/scratch/prc.out"
procmail: Acquiring kernel-lock
procmail: Unlocking "/home/myself/scratch/prc.out.lock"
Subject: FMSG:219
Folder: /home/myself/scratch/prc.out 8312
[168]%
我的〜/.procmailrc非常简单:
My ~/.procmailrc is very simple:
SHELL=/bin/sh
PATH=/bin:/usr/bin/:/sbin:/usr/sbin:$PATH
MAILDIR=$HOME/scratch # this is a symlink to a scratch disk
DEFAULT=$HOME/scratch/prc.out
VERBOSE=yes
LOGFILE=/home/myself/procmail.log
LOGABSTRACT=yes
LINEBUF=65535
:0
* ^Content-Type: *text/plain
{
:0 fbw
* ^Content-Transfer-Encoding: *base64
| $HOME/mmencode -u -b
:0 Afhw
| formail -I "Content-Transfer-Encoding: 8bit"
}
这是邮件文件的开头:
Return-Path: <unknown>
Delivered-To: unknown
From: <user1>
To: ole <user2>
Date: Mon, 20 Jul 2015 14:46:49 +0200
Subject: FMSG:219
Message-ID: <6959f239-gf41-4339-a526-a0337a17a9ba@test.local>
Accept-Language: en-US
Content-Language: en-US
Content-Type: multipart/mixed;
boundary="_002_6959f239a4d111111111111111111111111111111oletestl_"
MIME-Version: 1.0
--_002_6959f239a4d111111111111111111111111111111oletestl_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
--_002_6959f239a4d111111111111111111111111111111oletestl_
Content-Type: application/x-ole-envelope; name="20150720"
Content-Description: ole envelope
Content-Disposition: attachment; filename="20150720"; size=5528;
creation-date="Mon, 20 Jul 2015 12:46:52 GMT";
modification-date="Mon, 20 Jul 2015 12:46:52 GMT"
Content-Transfer-Encoding: base64
SDRzSUFBQUFBQUFBQzYxWFdZK2pXTEordnBiOEgxTDEwZzhvaDgxZ3V6dXJSb2ZGZ0EzWWJHWVp6
UU83d1d4bU1kaS8vaDY3DQpNcnV5ZW5wNjVrbzNKU3NoNG9zNHNaOUFrUlQrOVJpM1hWWlh2Nzdn
THQzOUFsMTVsVm5vQmg4TS8vL0hIS3ZqblA0NzRQMkZtdjJ0NDlpSDYzb2h2NkhzamYvdC9IVUZS
...
--_002_6959f239a4d6959f239a4d111111111111111111111111111111oletestl_
如果我尝试匹配"Content-Type:multipart/mixed",我实际上会得到一个匹配项:
If I try to match on "Content-Type: multipart/mixed" I do in fact get a match:
procmail: Match on "^Content-Type: multipart/mixed;"
procmail: No match on "^Content-Transfer-Encoding: *base64"
,但不包含以下内容...:(
but then not on the following ones... :(
尝试
procmail: No match on "^Content-Type: application/x-ole-envelope"
我想念什么?
谢谢
推荐答案
正则表达式上的消息 header 中没有匹配项.如果要在正文中找到匹配项(包括但绝不限于MIME正文部分标题),请使用B
标志;否则,请使用B
标志.但是适当的MIME支持会比这复杂得多,仅凭Procmail几乎是不可能的.
There is no match in the message header on the regex. If you want to find a match in the body (including, but by no means limited to, MIME body part headers), use a B
flag; but proper MIME support is going to be a lot more complex than that, and is next to impossible to do in Procmail alone.
您要复制的配方专门用于规范单部分text/plain
消息,而不是多部分.
The recipe you are copying is very specifically for normalizing single-part text/plain
messages, not multiparts.
您的问题非常笼统,所以我只能在广义上提出替代方案.也许根据某些正则表达式标准,将消息通过管道发送到 munpack
很有可能用Procmail表达;但对于更复杂的内容,也许可以通过管道传递到专用的Python(或Perl或Ruby等)脚本.
Your question is very general, so I can only suggest alternatives in broad terms. Maybe pipe the message to something like munpack
, possibly based on some regex criteria which may well be possible to express in Procmail; but for anything more sophisticated, maybe pipe to a specialized Python (or Perl, or Ruby, etc) script.
这篇关于procmail给出"no match"在内容类型上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!