Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a linux email client that can run on command line and can be configured to fetch and automatically save attachments to the filesystem?

Im currently using Thunderbird and it has a nice add-on called 'Attachment extractor' which automatically downloads attachments to the filesystem once the mail arrives. My problem is I want to run a custom php script the can process the attached file once it arrives.


share|improve this question

if you are receiving the email locally, metamail can probably do what you're looking for. many linux distros have a package for metamail.

here's a little information about it: http://www.cs.umd.edu/faq/mime.html

Otherwise, you may be able to work something out with fetchmail + procmail.

share|improve this answer

You can use fetchmail and procmail to do this. Procmail can be configured to execute a script that tests if an email has any mime encoded attachments (this could be as simple as just grepping the file for the MIME header) and then invokes munpack if it has.

Procmail can execute pretty much anything you want, so you should be able to get it to run your php script or a shell wrapper.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.