Extracting Attachments

Julian Field MailScanner at ecs.soton.ac.uk
Thu Feb 19 11:23:14 GMT 2009



On 17/2/09 21:58, Mark Wold wrote:
> I have a client that wants to email me PDF files so that I can convert 
> them to TIFF images and then forward them along. They want the process 
> to work 24/7. So instead of having a user who's job it is to grab the 
> attachments and perform the work, I would like to see if I can get 
> MailScanner to watch for emails coming into a specific user, extract 
> and store the attachments to a predefined directory in the system, and 
> then move on to other messages. I can easily then takes the PDF and 
> perform the conversions and forward it on.
>
> Does anyone know if I can do this extracting with MailScanner?
Write an SA rule that detects the messages you're interested in. Then 
use SpamAssassin Rule Actions to store those messages in individual 
files in a directory somewhere. Then have a cron job running every few 
minutes that picks up any files in that directory, extracts the 
attachment from them (there are various unmime tools that will do this 
for you from the command-line), and pump them through your converter. 
Then take the resulting TIFF images, turn them into attachments 
(uuencode will do this I believe with a base64-specific command-line 
switch) and manually construct a message around the base64-encoded data. 
That's easy enough to do by hand. Just create a very simple one in your 
email app, mail it to yourself and look at the resulting rfc822 message 
file. A few echo and cat commands in a shell script will be quite 
sufficient. Then call sendmail -t to send the message to the intended 
recipient.

Just divide the problem up into a few steps, and write each step in 
turn, which you should find very easy in a shell script.

I do something related to this for someone here, but it's different 
enough that the code wouldn't really help you much, sorry.

Jules

-- 
Julian Field MEng CITP CEng
www.MailScanner.info
Buy the MailScanner book at www.MailScanner.info/store

MailScanner customisation, or any advanced system administration help?
Contact me at Jules at Jules.FM

PGP footprint: EE81 D763 3DB0 0BFD E1DC 7222 11F6 5947 1415 B654
PGP public key: http://www.jules.fm/julesfm.asc


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



More information about the MailScanner mailing list