Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Save attachment to disk from an mbox format file

Posted on 2003-10-30
3
Medium Priority
?
919 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
3 Comments
 
LVL 20

Accepted Solution

by:
Gns earned 720 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 280 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

Industry Leaders: 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

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
I have written articles previously comparing SARDU and YUMI.  I also included a couple of lines about Easy2boot (easy2boot.com).  I have now been using, and enjoying easy2boot as my sole multiboot utility for some years and realize that it deserves …
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses
Course of the Month6 days, 12 hours left to enroll

783 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