Solved

Save attachment to disk from an mbox format file

Posted on 2003-10-30
3
868 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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,…
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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.

743 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now