Solved

Save attachment to disk from an mbox format file

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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
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…
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…
Suggested Courses

627 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