Pergunta

This is my first post here and I am a bit of a nub. I am looking to pass text from a MySQL database through spamassains spamc client. I can do it by writing to a file and then passing this file into spamc as in spamc < 'textfile.txt' but this is slow, due to the disk read/writes.

Does anyone know how to do this directly?

Foi útil?

Solução

Echo the query into the command line client in batch mode via a pipe, then pipe the output to spamc:

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

I am assuming you are selecting complete email messages from your database. If not, you will receive several spam flags for missing headers. Here's an example I just ran...

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
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top