Solved

Save attachment to disk from an mbox format file

Posted on 2003-10-30
3
894 Views
Last Modified: 2013-12-15
Hello,
  I just created an account on my linux box that will receive an email with an attachment once per day. I would like to make a script that will read the /var/spool/mail/userxx file and get ONLY the attachment and save it to disk (ie /var/www/htdocs/images/image.gif)
  I have tried a couple of things without success.....

Thank you very much

Alejandro Acosta,-
0
Comment
Question by:aacosta
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 20

Accepted Solution

by:
Gns earned 180 total points
ID: 9657209
You'll probably be best served by the metamail package.
man metamail
(if you have it) will tell more.

You'd be interrested in the -w flag (and possibly in the -r ... and some others:).
You might make it real nice, by combining it with procmail for that user, so that the decode/save occurs upon delivery to the user.

-- Glenn
0
 
LVL 38

Assisted Solution

by:yuzh
yuzh earned 70 total points
ID: 9667871
Glenn points you to the right direction.

You can use a mail filter eg,  procmail + metamail (eg, mimencode / mmencode, or mpack/munpack
 (MIME equivalent of uuencode/uudecode, )

or just write a little script (behave like auto_reply, but only extrach the attachments).

Have a look at the following page, to get some idea about how to write the script:
http://oldlook.experts-exchange.com/Networking/Email_Groupware/Sendmail/Q_20319762.html
0
 
LVL 1

Author Comment

by:aacosta
ID: 9671572
Hello,
  Thank boths, I did it using metamail and it worked perfect, thank you. I did not know the metamail command.
  My script is much easier...., it was just a combination between procmail and metamail.

-- cut here ---

:0
* ^Subject:.*PRUEBA
| /usr/bin/metamail -q -d; mv /tmp/netcat.blurb /home/aacosta/tmp

-- cut here ---

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question