procmail 在内容类型上给出 "no match"
procmail giving "no match" on content-type
我正在尝试让 procmail 解码 base64 编码的附件。首先,我遵循一个简单的食谱,可在此处找到:
但是,procmail 似乎找不到匹配项:
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 很简单:
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" 上匹配,我实际上得到了匹配:
procmail: Match on "^Content-Type: multipart/mixed;"
procmail: No match on "^Content-Transfer-Encoding: *base64"
但接下来的就不行了...:(
类似于
的尝试
procmail: No match on "^Content-Type: application/x-ole-envelope"
我错过了什么?
谢谢
消息 header 中的正则表达式没有匹配项。如果你想在 body 中找到匹配项(包括但不限于 MIME body 部分 headers),请使用 B
标志;但是适当的 MIME 支持将比这复杂得多,并且几乎不可能仅在 Procmail 中完成。
您正在复制的配方非常专门用于标准化 single-part text/plain
消息,而不是多部分。
你的问题很笼统,所以我只能给出笼统的建议。也许将消息传送到类似 munpack
的内容,可能基于一些很可能在 Procmail 中表达的正则表达式标准;但对于任何更复杂的东西,也许可以通过管道连接到专门的 Python(或 Perl,或 Ruby,等等)脚本。
我的 procmailrc 正在运行
VERBOSE=on
LOGFILE=$HOME/.procmail.log/procmail.`date +%Y%m%d`.log
LOGABSTRACT=yes
:0Wc:mailparser.lock
| /usr/bin/python /home/qq/mailparser.py > mailparser.log
:0
* ^content-Type:
{
# backup the complete mail first..
# you can leave out this part if you don't want a backup of the complete mail
:0c:
$HOME/fetchmail/mail_backup
:0fw
| uudeview -i +a +o -p $HOME/fetchmail/attachments -
}
当我尝试
* ^Content-Type: *text/plain
我找不到匹配项。
我正在尝试让 procmail 解码 base64 编码的附件。首先,我遵循一个简单的食谱,可在此处找到:
但是,procmail 似乎找不到匹配项:
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 很简单:
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" 上匹配,我实际上得到了匹配:
procmail: Match on "^Content-Type: multipart/mixed;"
procmail: No match on "^Content-Transfer-Encoding: *base64"
但接下来的就不行了...:(
类似于
的尝试procmail: No match on "^Content-Type: application/x-ole-envelope"
我错过了什么?
谢谢
消息 header 中的正则表达式没有匹配项。如果你想在 body 中找到匹配项(包括但不限于 MIME body 部分 headers),请使用 B
标志;但是适当的 MIME 支持将比这复杂得多,并且几乎不可能仅在 Procmail 中完成。
您正在复制的配方非常专门用于标准化 single-part text/plain
消息,而不是多部分。
你的问题很笼统,所以我只能给出笼统的建议。也许将消息传送到类似 munpack
的内容,可能基于一些很可能在 Procmail 中表达的正则表达式标准;但对于任何更复杂的东西,也许可以通过管道连接到专门的 Python(或 Perl,或 Ruby,等等)脚本。
我的 procmailrc 正在运行
VERBOSE=on
LOGFILE=$HOME/.procmail.log/procmail.`date +%Y%m%d`.log
LOGABSTRACT=yes
:0Wc:mailparser.lock
| /usr/bin/python /home/qq/mailparser.py > mailparser.log
:0
* ^content-Type:
{
# backup the complete mail first..
# you can leave out this part if you don't want a backup of the complete mail
:0c:
$HOME/fetchmail/mail_backup
:0fw
| uudeview -i +a +o -p $HOME/fetchmail/attachments -
}
当我尝试
* ^Content-Type: *text/plain
我找不到匹配项。