Best way to automatically copy out attachments from an email

Cameron Simpson cs at zip.com.au
Sun Jan 16 03:59:28 UTC 2011


On 12Jan2011 14:16, m.roth at 5-cent.us <m.roth at 5-cent.us> wrote:
| Matty Sarro wrote:
| > As of now here is my situation:
| > I am working on a system to aggregate IT data and logs. A number of
| > important data are gathered by a third party system. The only
| > immediate way I have to access the data is to have their system
| > automatically email me updates in CSV format every hour. If I set up a
| > mail client on the server, this shouldn't be a huge issue.
| >
| > However, is there a way to automatically open the emails, and copy the
| > attachments to a directory based on the filename? Kind of a weird
| > project, I know. Just looking for some ideas hence posting this on two
| > lists.
| 
| Well, they are presumably in std. MIME format, so you can strip it off,
| maybe with a filter either in your mail tool, or in the delivery system.
| procmail comes to mind.

1: Install metamail.
2: Try this script:
    http://www.cskk.ezoshosting.com/cs/css/bin/mailunpack

The particular metamail command you want is "metamail -w -x"; see the
man page for details.

The mailunpack script above just does a lot of the housekeeping and
automation you will doubtless want to do anyway; it does need a bunch of my
other scripts, see:

    http://www.cskk.ezoshosting.com/cs/css/

to get the lot, typically installing them in /opt/css for easy use.

Then all you need to do is use procmail to filter you email, and have it
pass the relevant emails to mailunpack with the right arguments (or of
course directly to "metamail -w -x" with some wrapping).

Anyway, you're welcome to the script for use or for inspection.

Cheers,
-- 
Cameron Simpson <cs at zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

If you push something hard enough, it will fall over.
[Fudd's first law of opposition]




More information about the redhat-list mailing list