Welcome to WebmasterWorld Guest from 54.196.238.210

Forum Moderators: bakedjake

Message Too Old, No Replies

Save MIME email attachment to disk

Seeking solution to receive e-mail, strip the attached file, and save.

     

venice

5:19 pm on Apr 14, 2011 (gmt 0)

5+ Year Member



Hopefully this is the right place for this thread, I've been searching for a solution to save attached image files sent by email, onto a linux server.

The reasoning behind this is as I'm getting older I'm finding I take photos for blog posts and forgotten I've done so. I want to take the photo > name it > email it > save it on the server so writers have it available for posts.

The Goal: Save MIME single email attachments to disk

Would apply to a specific email address intended for this purpose.

I send email with image attached and email received on server.

Attachment is removed from email and saved to a directory.

Example: Attached file img0001.jpg saved as... /home/public_html/images/img0001.jpg

OR if Possible

Attachment is removed from email and saved to a directory using email subject line as filename.

Example: Attached file img0001.jpg saved as red-widget.jpg in... /home/public_html/images

If file name already exists, new file gets appended -01.jpg or other.

Email gets deleted.

In searching WebmasterWorld and elsewhere, I've come across things like metamail, ripMIME and a PERL script, and I figure a script has to be written or modified to make it all happen.

Any tips on how best to accomplish this are appreciated.

mbabuskov

5:28 pm on Apr 14, 2011 (gmt 0)



You need to provide more information, for example where do you want e-mail to be extracted from? Is it POP3, IMAP server or local file or database storage?

venice

5:40 pm on Apr 14, 2011 (gmt 0)

5+ Year Member



Thanks for the reply. I believe it would be extracted from a local file. Right now mail goes to user directory in mail folder on domain.

Hoople

12:56 am on Apr 15, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Eudora and other email clients will do this. Some are scriptable after setting behavior in their GUI.

graeme_p

7:58 pm on Apr 15, 2011 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month



If its just a matter of parsing local email and extracting the attachments, you can probably do this with any of the major scripting languages. It looks to me like the email package in the Python standard library can do it for a start. Write a script, call it with a cron job.

You may be able to do it using the nmh command line email tools. I am not familiar with them, but the functionality to extract attachments exists.

dstiles

10:35 pm on Apr 15, 2011 (gmt 0)

WebmasterWorld Senior Member dstiles is a WebmasterWorld Top Contributor of All Time 5+ Year Member



Thunderbird can save the complete email (as a .eml file - just press Ctrl-S) or you can save individual or all attachments from an email to wherever you like.

venice

11:28 pm on Apr 15, 2011 (gmt 0)

5+ Year Member



Thanks everyone. Had a script written in php, working out the bugs now, hopefully up by tomorrow.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month