• 0

How to pull attachments out of email in ubuntu/postfix?


Question

I've been using an ubuntu VM running spamassassin +dcc + pyzor + razor +clamav + postfix to act as a gateway for filtering virus, spam, phising, and other nasty emails in front of an exchange server. It works great, except that auto learning is a little slow. The easiest way I can see of automatting a learning process, is to forward known spam/ham to seperate boxes on the system, (spam and ham, naturally), and then set up a cron job to have sa-learn learn from the box... (sa-learn --spam --mbox spam / sa-learn --ham --mbox ham)

I've tried forwarding messages from OWA to these boxes (fwd to spam@mailscanner.domain.local, etc) but it strips out the original headers. I can forward the spam/ham messages as attachments, but then I need to be able to pull the attachments out and have it learn. I've looked at mpack/munpack, but this only seems to pull non-text attachments out, unless you use the -t option, which then just pulls html/text, not the .eml attachment.

Can anyone recommend a linux tool that can take a mailbox and pull all the attachments out? My process was going to be something like follows for a cron job:


"unpack" /var/spool/mail/spam
sa-learn --spam /var/spool/mail/*.eml
rm -rf spam
rm -rf *.eml
"unpack" /var/spool/mail/ham
sa-learn --ham /var/spool/mail/*.eml
rm -rf ham
rm -rf *.eml

[/CODE]

unpack obviously would be whatever tool was best. Then I could just take a bunch of emails, forward as attachments to either the spam or ham accounts and have it learn on a schedule. I can't use direct forwarding because spamassassin reuqires the original headers, which outlook strips out when you forward messages, replacing with its own. Currently I've been forwarding as attachments to my gmail account, saving as *.eml or *.txt files, then copying to the ubuntu vm, and learning from that...but that takes a while and is not very automated. It would be much easier to forward back to the box as an attachment, have it stripped out and then learned.

Thanks!

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

This topic is now closed to further replies.