How to output quarantined msgs from SQL to file

Patrik Båt via amavis-users amavis-users at
Fri Mar 7 11:27:18 CET 2014

On tor 20 feb 2014 20:14:20, Deeztek Support via amavis-users wrote:
> On 2/19/2014 10:41 PM, Deeztek Support via amavis-users wrote:
>> On 2/19/2014 4:22 PM, Patrick Ben Koetter via amavis-users wrote:
>>> * Deeztek Support via amavis-users <support at>:
>>>> Is there a way to output msgs quarantined in mysql into a file and
>>>> then
>>>> feed that file to spamassassin for bayes training? Or is there a much
>>>> simpler way of doing this that I'm not aware of?
>>> You could use the Resend-format when you release messages and
>>> reroute them to
>>> a dedicated mailbox. Then feed the content of that mailbox to SA.
>>> p at rick
>> There are no mailboxes on the system I'm trying to do this on. It's a
>> relay server and I rather not get another server in the mix. I want
>> to see if I can accomplish it on the same system. Could I somehow
>> query the database and output the contents into a file and feed that
>> to spamassassin? Has anyone tried anything like this before. I can't
>> be the only one?
> Just in case anyone wants to know, I was able to query the quarantine
> table using the mail_id of the message sorting by chunk_ind ascending
> and I was able to output the query output into a file. I then fed that
> file into spamassassin using the sa-learn command and it looks like it
> worked like a charm.

I'm doing it like this:

select UNCOMPRESS(mail_text) from <table> where mail_id='XXXXX' order 
by chunk_ind into outfile "/tmp/email.eml" FIELDS ESCAPED BY '';

Else you will get it escaped, that’s bad!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 538 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the amavis-users mailing list