将文本从MySQL传递到spamassassins Spamc客户端

时间:2011-12-01 13:44:15

标签: mysql spamassassin

这是我在这里发表的第一篇文章,我有点像个小组。我希望通过spamassains spamc客户端从MySQL数据库传递文本。我可以通过写入文件然后将此文件传递到spamc中来执行此操作,如spamc < 'textfile.txt'中所示,但由于磁盘读/写,这很慢。

有谁知道如何直接这样做?

1 个答案:

答案 0 :(得分:1)

通过管道以批处理方式将查询回显到命令行客户端,然后将输出通过管道输送到spamc:

echo "SELECT col1, col2 FROM yourtable" | mysql --batch -uuser -ppassword | spamc

我假设您正在从数据库中选择完整的电子邮件。如果没有,您将收到几个丢失标题的垃圾邮件标记。这是我刚刚跑过的一个例子......

X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on
        localhost
X-Spam-Flag: YES
X-Spam-Level: *****
X-Spam-Status: Yes, score=5.5 required=5.0 tests=MISSING_DATE,MISSING_FROM,
        MISSING_HEADERS,MISSING_MID,MISSING_SUBJECT,NO_HEADERS_MESSAGE,NO_RECEIVED,
        NO_RELAYS,TVD_SPACE_RATIO autolearn=no version=3.3.1
X-Spam-Report:
        * -0.0 NO_RELAYS Informational: message was not relayed via SMTP
        *  1.2 MISSING_HEADERS Missing To: header
        *  0.1 MISSING_MID Missing Message-Id: header
        *  1.8 MISSING_SUBJECT Missing Subject: header
        *  1.0 MISSING_FROM Missing From: header
        * -0.0 NO_RECEIVED Informational: message has no Received headers
        *  0.0 TVD_SPACE_RATIO TVD_SPACE_RATIO
        *  1.4 MISSING_DATE Missing Date: header
        *  0.0 NO_HEADERS_MESSAGE Message appears to be missing most RFC-822
        *      headers