Solved

Save attachment to disk from an mbox format file

Posted on 2003-10-30
3
887 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 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
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…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.

839 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