{"id":1930,"date":"2016-08-19T00:26:54","date_gmt":"2016-08-19T08:26:54","guid":{"rendered":"http:\/\/systemsolver.com\/StatlerBlog\/?p=1930"},"modified":"2016-08-19T00:26:54","modified_gmt":"2016-08-19T08:26:54","slug":"linux-bash-extract-attachment-from-email","status":"publish","type":"post","link":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/2016\/08\/19\/linux-bash-extract-attachment-from-email\/","title":{"rendered":"Linux bash extract attachment from email"},"content":{"rendered":"<ol>\n<li>get mail and put into a directory<\/li>\n<li>extract parts of email<\/li>\n<li>save relevant parts to new directory<\/li>\n<li>delete all other parts<\/li>\n<\/ol>\n<p>simplest?<\/p>\n<p><a href=\"https:\/\/antipaucity.com\/2014\/04\/24\/automatically-extract-email-attachments-with-common-linux-tools\/\">https:\/\/antipaucity.com\/2014\/04\/24\/automatically-extract-email-attachments-with-common-linux-tools\/<\/a><\/p>\n<pre style=\"padding-left: 30px;\">$ yum install mpack\n\n$ cat extract-attach.sh \n#!\/bin\/bash\nrm -rf ~\/attachtmp\nmkdir ~\/attachtmp\nmv ~\/Maildir\/new\/* ~\/attachtmp\ncd ~\nmunpack ~\/attachtmp\/*\nrm -rf ~\/attachtmp\n\n$ crontab -l\n*\/5 * * * *\t~\/extract-attach.sh<\/pre>\n<p>messier?<\/p>\n<p><a href=\"http:\/\/www.pldaniels.com\/ripmime\/#workswith\">http:\/\/www.pldaniels.com\/ripmime\/#workswith<\/a><\/p>\n<p>Now just need simple &#8216;get email&#8217; program<\/p>\n<p><a href=\"https:\/\/opensource.com\/life\/15\/8\/top-4-open-source-command-line-email-clients\">https:\/\/opensource.com\/life\/15\/8\/top-4-open-source-command-line-email-clients<\/a><\/p>\n<p><a href=\"https:\/\/wiki.archlinux.org\/index.php\/Getmail\">https:\/\/wiki.archlinux.org\/index.php\/Getmail<\/a><\/p>\n<pre style=\"padding-left: 30px;\">[retriever]\ntype = SimplePOP3SSLRetriever\nserver = pop.gmail.com\nusername = username@gmail.com\nport = 995\npassword = password\n\n[destination]\ntype = Maildir\npath = ~\/mail\/<\/pre>\n<p><a href=\"http:\/\/www.fetchmail.info\/\">http:\/\/www.fetchmail.info\/<\/a><\/p>\n<p>Once the .fetchmailrc file is configured, fetchmail can be invoked simply by issuing the following command:<\/p>\n<pre style=\"padding-left: 30px;\">fetchmail<\/pre>\n<p>.fetchmailrc<\/p>\n<pre style=\"padding-left: 30px;\">poll example.com protocol pop3 username \"username\" password \"XXX\"<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>get mail and put into a directory extract parts of email save relevant parts to new directory 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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-1930","post","type-post","status-publish","format-standard","hentry","category-general"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/posts\/1930","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/comments?post=1930"}],"version-history":[{"count":0,"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/posts\/1930\/revisions"}],"wp:attachment":[{"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/media?parent=1930"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/categories?post=1930"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/tags?post=1930"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}