{"id":14576,"date":"2013-08-02T21:00:22","date_gmt":"2013-08-02T12:00:22","guid":{"rendered":"http:\/\/www.sssg.org\/blogs\/hiro345\/?p=14576"},"modified":"2013-08-03T20:01:29","modified_gmt":"2013-08-03T11:01:29","slug":"javamail%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e7%b0%a1%e5%8d%98eml%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e8%aa%ad%e3%81%bf%e8%be%bc%e3%81%bf","status":"publish","type":"post","link":"https:\/\/www.hiro345.net\/blogs\/hiro345\/archives\/14576.html","title":{"rendered":"JavaMail\u3092\u4f7f\u3063\u3066\u7c21\u5358eml\u30d5\u30a1\u30a4\u30eb\u8aad\u307f\u8fbc\u307f"},"content":{"rendered":"<p>TODO\u30d5\u30a9\u30eb\u30c0\u306b\u307e\u3068\u3081\u305f\u30e1\u30fc\u30eb\u306eSubject\u4e00\u89a7\u304c\u6b32\u3057\u3044\u3068\u304d\u304c\u3042\u308a\u307e\u3059\u3002\u30e1\u30fc\u30e9\u3092\u958b\u3044\u3066\u3044\u3061\u3044\u3061\u30b3\u30d4\u30da\u3059\u308b\u306e\u306f\u9762\u5012\u306a\u306e\u3067\u3059\u304c\u3001\u4f55\u304b\u826f\u3044\u65b9\u6cd5\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002<br \/>\n<!--more--><br \/>\n\u305d\u3093\u306a\u3068\u304d\u306fIMAP\u30b5\u30fc\u30d0\u3092Maildir\u5f62\u5f0f\u3067\u52d5\u304b\u3057\u3066\u304a\u304f\u3068\u4f55\u304b\u3068\u4fbf\u5229\u3067\u3059\u3002IMAP\u30b5\u30fc\u30d0\u306e\u3042\u308b\u30d5\u30a9\u30eb\u30c0\u3078\u4e00\u89a7\u306b\u3057\u305f\u3044\u30e1\u30fc\u30eb\u3092\u653e\u308a\u8fbc\u3093\u3067\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u4e00\u89a7\u3092\u53d6\u5f97\u3059\u308c\u3070\u3044\u3044\u306e\u3067\u3059\u3002\u307e\u3041\u3001IMAP\u30b5\u30fc\u30d0\u3067\u306a\u304f\u3066\u3082Maildir\u5f62\u5f0f\u3067\u30e1\u30fc\u30eb\u3092\u4fdd\u5b58\u3059\u308b\u30e1\u30fc\u30e9\u3092\u4f7f\u3063\u3066\u30ed\u30fc\u30ab\u30eb\u3067\u51e6\u7406\u3057\u3066\u3082\u3044\u3044\u3067\u3059\u306d\u3002<\/p>\n<p>\u30d7\u30ed\u30b0\u30e9\u30e0\u306fJavaMail\u3092\u4f7f\u3044\u307e\u3059\u3002Maildir\u5f62\u5f0f\u3067\u4fdd\u5b58\u3055\u308c\u308b\u30e1\u30fc\u30eb\u306f\u3044\u308f\u3086\u308beml\u30d5\u30a1\u30a4\u30eb\u3067\u3059\u304b\u3089\u3001\u6b21\u306e\u3088\u3046\u306b\u3057\u3066\u7c21\u5358\u306b\u51e6\u7406\u304c\u3067\u304d\u307e\u3059\u3002\u30b5\u30f3\u30d7\u30eb\u3067\u306fSubject\u4ee5\u5916\u3082\u53d6\u5f97\u3057\u3066\u8868\u793a\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u624b\u5143\u3067\u306f\u30bf\u30a4\u30c8\u30eb\u3060\u3051\u306b\u3057\u3066\u3001\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8\u3068\u7d44\u307f\u5408\u308f\u305b\u3066\u4e00\u89a7\u3092\u53d6\u5f97\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u3046\u3044\u3046\u3053\u3068\u304c\u3067\u304d\u308b\u3068\u3001\u30e1\u30fc\u30eb\u3068\u4ed6\u306e\u30b7\u30b9\u30c6\u30e0\u3068\u3092\u9023\u643a\u3055\u305b\u305f\u308a\u3059\u308b\u3053\u3068\u304c\u7c21\u5358\u306b\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u304b\u3089\u3001\u4f7f\u3063\u3066\u307f\u308b\u3068\u697d\u3057\u3044\u3067\u3059\u3088\uff01<\/p>\n<pre class=\"brush: java; gutter: true\">\r\nimport java.util.*;\r\nimport java.io.*;\r\nimport javax.mail.*;\r\nimport javax.mail.internet.*;\r\npublic class App {\r\n   public static void main(String args[]) throws Exception{\r\n       if (args.length &lt; 1) {\r\n         System.out.println(&quot;usage: java -jar JemlReader.jar filename.eml&quot;);\r\n         System.exit(0);\r\n       }\r\n       String f = args[0];\r\n       display(new File(f));\r\n   }\r\n   public static void display(File emlFile) throws Exception{\r\n        Properties props = System.getProperties();\r\n        props.put(&quot;mail.host&quot;, &quot;smtp.dummydomain.com&quot;);\r\n        props.put(&quot;mail.transport.protocol&quot;, &quot;smtp&quot;);\r\n\r\n        Session mailSession = Session.getDefaultInstance(props, null);\r\n        InputStream source = new FileInputStream(emlFile);\r\n        MimeMessage message = new MimeMessage(mailSession, source);\r\n        System.out.println(&quot;Subject : &quot; + message.getSubject());\r\n        System.out.println(&quot;From : &quot; + message.getFrom()[0]);\r\n        System.out.println(&quot;--------------&quot;);\r\n        System.out.println(&quot;Body : &quot; +  message.getContent());\r\n    }\r\n}\r\n<\/pre>\n<p>JavaMail\u306f\u672c\u5bb6\u304b\u3089\u53d6\u5f97\u3057\u3066\u3082\u826f\u3044\u3067\u3059\u3057\u3001maven\u306a\u3089pom.xml\u3078\u4f9d\u5b58\u95a2\u4fc2\u3092\u8ffd\u52a0\u3059\u308b\u3060\u3051\u3067\u3059\u3002\u624b\u5143\u3067\u306fquick-start\u306e\u30a2\u30d7\u30ea\u3092\u4f5c\u3063\u3066\u3001pom.xml\u3092\u3061\u3087\u3063\u3068\u66f8\u304d\u63db\u3048\u305f\u3060\u3051\u3059\u3050\u306b\u4f7f\u3048\u307e\u3057\u305f\u3002\u4fbf\u5229\u3067\u3059\u306d\u3002\u4e16\u306e\u4e2d maven\u3088\u308a\u3082gradle \u304c\u512a\u52e2\u306b\u306a\u308a\u3064\u3064\u3042\u308b\u3088\u3046\u3067\u3059\u304c&#8230;<\/p>\n<pre class=\"brush: xml; gutter: true\">\r\n&lt;project xmlns=&quot;http:\/\/maven.apache.org\/POM\/4.0.0&quot; xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot;\r\n  xsi:schemaLocation=&quot;http:\/\/maven.apache.org\/POM\/4.0.0 http:\/\/maven.apache.org\/maven-v4_0_0.xsd&quot;&gt;\r\n  &lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt;\r\n  &lt;groupId&gt;org.sssg.soft.jemlreader&lt;\/groupId&gt;\r\n  &lt;artifactId&gt;JemlReader&lt;\/artifactId&gt;\r\n  &lt;packaging&gt;jar&lt;\/packaging&gt;\r\n  &lt;version&gt;1.0&lt;\/version&gt;\r\n  &lt;name&gt;JemlReader&lt;\/name&gt;\r\n  &lt;url&gt;http:\/\/maven.apache.org&lt;\/url&gt;\r\n  &lt;properties&gt;\r\n    &lt;project.build.sourceEncoding&gt;UTF-8&lt;\/project.build.sourceEncoding&gt;\r\n  &lt;\/properties&gt;\r\n  &lt;build&gt;\r\n    &lt;plugins&gt;\r\n      &lt;plugin&gt;\r\n        &lt;groupId&gt;org.apache.maven.plugins&lt;\/groupId&gt;\r\n        &lt;artifactId&gt;maven-jar-plugin&lt;\/artifactId&gt;\r\n        &lt;version&gt;2.4&lt;\/version&gt;\r\n        &lt;configuration&gt;\r\n          &lt;archive&gt;\r\n            &lt;manifest&gt;\r\n              &lt;mainClass&gt;org.sssg.soft.jemlreader.App&lt;\/mainClass&gt;\r\n              &lt;packageName&gt;org.sssg.soft.jemlreader&lt;\/packageName&gt;\r\n              &lt;addClasspath&gt;true&lt;\/addClasspath&gt;\r\n              &lt;addExtensions&gt;true&lt;\/addExtensions&gt;\r\n              &lt;classpathPrefix&gt;lib&lt;\/classpathPrefix&gt;\r\n            &lt;\/manifest&gt;\r\n          &lt;\/archive&gt;\r\n        &lt;\/configuration&gt;\r\n      &lt;\/plugin&gt;\r\n    &lt;\/plugins&gt;\r\n  &lt;\/build&gt;\r\n  &lt;dependencies&gt;\r\n    &lt;dependency&gt;\r\n      &lt;groupId&gt;javax.mail&lt;\/groupId&gt;\r\n      &lt;artifactId&gt;mail&lt;\/artifactId&gt;\r\n      &lt;version&gt;1.4&lt;\/version&gt;\r\n    &lt;\/dependency&gt;\r\n    &lt;dependency&gt;\r\n      &lt;groupId&gt;junit&lt;\/groupId&gt;\r\n      &lt;artifactId&gt;junit&lt;\/artifactId&gt;\r\n      &lt;version&gt;3.8.1&lt;\/version&gt;\r\n      &lt;scope&gt;test&lt;\/scope&gt;\r\n    &lt;\/dependency&gt;\r\n  &lt;\/dependencies&gt;\r\n&lt;\/project&gt;\r\n<\/pre>\n<ul>\n<li><a type=\"amzn\" asin=\"0596517335\">Maven: The Definitive Guide <\/a><\/li>\n<li><a type=\"amzn\" asin=\"B005JYRL3G\">Apache Maven 3 Cookbook <\/a><\/li>\n<li><a type=\"amzn\" asin=\"B005EI85J6\">Building and Testing with Gradle <\/a><\/li>\n<li><a type=\"amzn\" asin=\"1617291307\">Gradle in Action<\/a><\/li>\n<li><a type=\"amzn\" asin=\"B00DZ4I8XE\">Gradle Beyond the Basics <\/a><\/li>\n<\/ul>\n<div>\n<iframe loading=\"lazy\" style=\"width: 120px; height: 240px;\" src=\"\/\/rcm-jp.amazon.co.jp\/e\/cm?t=hiro345-22&amp;o=9&amp;p=8&amp;l=as1&amp;asins=0596517335&amp;ref=tf_til&amp;fc1=000000&amp;IS2=1&amp;lt1=_blank&amp;m=amazon&amp;lc1=0000FF&amp;bc1=000000&amp;bg1=FFFFFF&amp;f=ifr\" height=\"240\" width=\"320\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><iframe loading=\"lazy\" style=\"width: 120px; height: 240px;\" src=\"\/\/rcm-jp.amazon.co.jp\/e\/cm?t=hiro345-22&amp;o=9&amp;p=8&amp;l=as1&amp;asins=B005JYRL3G&amp;ref=tf_til&amp;fc1=000000&amp;IS2=1&amp;lt1=_blank&amp;m=amazon&amp;lc1=0000FF&amp;bc1=000000&amp;bg1=FFFFFF&amp;f=ifr\" height=\"240\" width=\"320\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><iframe loading=\"lazy\" style=\"width: 120px; height: 240px;\" src=\"\/\/rcm-jp.amazon.co.jp\/e\/cm?t=hiro345-22&amp;o=9&amp;p=8&amp;l=as1&amp;asins=B005EI85J6&amp;ref=tf_til&amp;fc1=000000&amp;IS2=1&amp;lt1=_blank&amp;m=amazon&amp;lc1=0000FF&amp;bc1=000000&amp;bg1=FFFFFF&amp;f=ifr\" height=\"240\" width=\"320\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><iframe loading=\"lazy\" style=\"width: 120px; height: 240px;\" src=\"\/\/rcm-jp.amazon.co.jp\/e\/cm?t=hiro345-22&amp;o=9&amp;p=8&amp;l=as1&amp;asins=1617291307&amp;ref=tf_til&amp;fc1=000000&amp;IS2=1&amp;lt1=_blank&amp;m=amazon&amp;lc1=0000FF&amp;bc1=000000&amp;bg1=FFFFFF&amp;f=ifr\" height=\"240\" width=\"320\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><iframe loading=\"lazy\" style=\"width: 120px; height: 240px;\" src=\"\/\/rcm-jp.amazon.co.jp\/e\/cm?t=hiro345-22&amp;o=9&amp;p=8&amp;l=as1&amp;asins=B00DZ4I8XE&amp;ref=tf_til&amp;fc1=000000&amp;IS2=1&amp;lt1=_blank&amp;m=amazon&amp;lc1=0000FF&amp;bc1=000000&amp;bg1=FFFFFF&amp;f=ifr\" height=\"240\" width=\"320\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>TODO\u30d5\u30a9\u30eb\u30c0\u306b\u307e\u3068\u3081\u305f\u30e1\u30fc\u30eb\u306eSubject\u4e00\u89a7\u304c\u6b32\u3057\u3044\u3068\u304d\u304c\u3042\u308a\u307e\u3059\u3002\u30e1\u30fc\u30e9\u3092\u958b\u3044\u3066\u3044\u3061\u3044\u3061\u30b3\u30d4\u30da\u3059\u308b\u306e\u306f\u9762\u5012\u306a\u306e\u3067\u3059\u304c\u3001\u4f55\u304b\u826f\u3044\u65b9\u6cd5\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[1207,894],"class_list":["post-14576","post","type-post","status-publish","format-standard","hentry","category-java","tag-java","tag-javamail"],"_links":{"self":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/14576","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/comments?post=14576"}],"version-history":[{"count":1,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/14576\/revisions"}],"predecessor-version":[{"id":14577,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/14576\/revisions\/14577"}],"wp:attachment":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/media?parent=14576"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/categories?post=14576"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/tags?post=14576"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}