{"id":1384,"date":"2008-11-24T21:27:49","date_gmt":"2008-11-25T01:27:49","guid":{"rendered":"http:\/\/blogs.n1zyy.com\/n1zyy\/?p=1384"},"modified":"2008-11-24T21:27:49","modified_gmt":"2008-11-25T01:27:49","slug":"imap-from-perl","status":"publish","type":"post","link":"https:\/\/blogs.n1zyy.com\/n1zyy\/2008\/11\/24\/imap-from-perl\/","title":{"rendered":"IMAP from Perl"},"content":{"rendered":"<p>I&#8217;m quickly finding it necessary to get back &#8220;into&#8221; scripting: I&#8217;d throw stuff together here and there, but it&#8217;s been a while since I wrote anything more than a dozen lines or so, and I haven&#8217;t done anything with Perl in far too long.<\/p>\n<p>For a project I&#8217;m going to be doing, I just discovered something awesome: Perl&#8217;s <tt>Net::IMAP::Simple<\/tt><\/p>\n<p>This code doesn&#8217;t actually do much, but it&#8217;s still pretty neat how simple Perl makes it:<\/p>\n<pre>\n# Open the connection\n$server = new Net::IMAP::Simple(\"$servername\") or die(\"Couldn't open connection to server $servernamen\");\nprint \"Connected to $servername...n\";\n\n# Authenticate\n$server->login(\"$user\", \"$pass\") or die(\"Couldn't authenticate with server as $user : $passn\");\nprint \"Authenticated as $user...n\";\n\n# Get a message count (frivilous)\n$message_count = $server->select($folder) or die(\"Selecting folder $folder failed.n\");\nprint \"Connected with $message_count messages...n\";\n\n# Print a list of all folders?\n@folders = $server->mailboxes();\nforeach $x (@folders) {\n        print \"$xn\";\n}\n<\/pre>\n<p>With a little looping magic, it should be easy enough to extract whatever&#8217;s needed from each message! (There are some more complex IMAP scripts, but, well, they&#8217;re not called IMAP::<i>Simple<\/i>&#8230;)<\/p>","protected":false},"excerpt":{"rendered":"<p>I&#8217;m quickly finding it necessary to get back &#8220;into&#8221; scripting: I&#8217;d throw stuff together here and there, but it&#8217;s been a while since I wrote anything more than a dozen lines or so, and I haven&#8217;t done anything with Perl &hellip; <a href=\"https:\/\/blogs.n1zyy.com\/n1zyy\/2008\/11\/24\/imap-from-perl\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1384","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts\/1384","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/comments?post=1384"}],"version-history":[{"count":0,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts\/1384\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/media?parent=1384"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/categories?post=1384"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/tags?post=1384"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}