Skip to content

antipaucity

fighting the lack of good ideas

automatically extract email attachments with common linux tools

Posted on 24 April 201421 April 2014 By antipaucity 3 Comments on automatically extract email attachments with common linux tools

I had need to automatically process emails to a specific address to pull attachments out, and this is how I did it:

$ yum install mpack

$ cat extract-attach.sh 
#!/bin/bash
rm -rf ~/attachtmp
mkdir ~/attachtmp
mv ~/Maildir/new/* ~/attachtmp
cd ~
munpack ~/attachtmp/*
rm -rf ~/attachtmp

$ crontab -l
*/5 * * * *	~/extract-attach.sh

Why, you may ask? Because I get a report a few times per day to the email address in question.


Note – this runs in my crontab every 5 minutes on a CentOS 6 x64 server; I’m sure the process is similar/identical on other distros, but I haven’t personally tried.

technical, tutorial Tags:attachment, centos, cron, email, how-to, linux, munpack, tutorial

Post navigation

Previous Post: kingmakers by karl ernest meyer and shareen blair brysac
Next Post: 35 great questions, part 4

More Related Articles

update: keeping your let’s encrypt certs up-to-date technical
rethinking pi-hole (again) technical
debugging authorized_keys and ssh education
a break from digitalia personal
create your own clustered cloud storage system with moosefs and pydio personal
sometimes i’m off technical

Comments (3) on “automatically extract email attachments with common linux tools”

  1. Will Farmer says:
    6 July 2016 at 08:16

    Thanks for this. I’m attempting to use it in conjunction with an automated upload to FTP for reports. This makes it a whole lot easier.

  2. Warren says:
    7 July 2016 at 01:06

    Happy it could help you 🙂

  3. Daniel Bunte says:
    20 October 2017 at 03:53

    Thanks a lot, you saved my day! 🙂

Comments are closed.

April 2014
S M T W T F S
 12345
6789101112
13141516171819
20212223242526
27282930  
« Mar   May »
  • Patrick Henry 23 March 1775
  • Reincarnation by Wallace McCrae (adapted by Warren Myers)
  • Famed was Beowulf
  • Fuzzy Wuzzy (anonymous)
  • One bright morning in the middle of the night (various)

Books

  • Debugging and Supporting Software Systems
  • Storage Series

External

  • Backblaze
  • Cirkul
  • Digital Ocean
  • Fundrise
  • Great Big Purple Sign
  • Password Generator
  • PayPal
  • Tech News Channel on Telegram
  • Wish List

Other Blogs

  • Abiding in Hesed
  • Chris Agocs
  • Eric Hydrick
  • Jay Loden
  • Paragraph
  • skh:tec
  • Tech News Channel on Telegram
  • Veritas Equitas

Profiles

  • LinkedIn
  • Server Fault
  • Stack Overflow
  • Super User
  • Telegram
  • Twitter

Resume

  • LinkedIn
  • Resume (PDF)

Services

  • Datente
  • IP check
  • Password Generator
  • Tech News Channel on Telegram

Support

  • Backblaze
  • Built Bar
  • Cirkul
  • Digital Ocean
  • Donations
  • Fundrise
  • PayPal
  • Robinhood
  • Wish List

Copyright © 2023 antipaucity.

Powered by PressBook Green WordPress theme