Linux bash extract attachment from email

  1. get mail and put into a directory
  2. extract parts of email
  3. save relevant parts to new directory
  4. delete all other parts

simplest?

https://antipaucity.com/2014/04/24/automatically-extract-email-attachments-with-common-linux-tools/

$ 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

messier?

http://www.pldaniels.com/ripmime/#workswith

Now just need simple ‘get email’ program

https://opensource.com/life/15/8/top-4-open-source-command-line-email-clients

https://wiki.archlinux.org/index.php/Getmail

[retriever]
type = SimplePOP3SSLRetriever
server = pop.gmail.com
username = username@gmail.com
port = 995
password = password

[destination]
type = Maildir
path = ~/mail/

http://www.fetchmail.info/

Once the .fetchmailrc file is configured, fetchmail can be invoked simply by issuing the following command:

fetchmail

.fetchmailrc

poll example.com protocol pop3 username "username" password "XXX"