<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Imap on Micha Kops&#39; Tech Notes</title>
    <link>https://www.hascode.com/tags/imap/</link>
    <description>Recent content in Imap on Micha Kops&#39; Tech Notes</description>
    <generator>Hugo</generator>
    <language>en</language>
    <copyright>Copyright © 2010 - 2025 Micha Kops. #6b8ec22b54a31298599051b21668c39a77055d1c</copyright>
    <lastBuildDate>Wed, 13 Feb 2013 00:00:00 +0100</lastBuildDate>
    <atom:link href="https://www.hascode.com/tags/imap/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Using Apache Camel with Scala and the Camel Scala DSL</title>
      <link>https://www.hascode.com/using-apache-camel-with-scala-and-the-camel-scala-dsl/</link>
      <pubDate>Wed, 13 Feb 2013 00:00:00 +0100</pubDate>
      <guid>https://www.hascode.com/using-apache-camel-with-scala-and-the-camel-scala-dsl/</guid>
      <description>&lt;div id=&#34;preamble&#34;&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;Whenever I encounter a situation where I have to mix a blend of different services and endpoints and apply one or more of the traditional enterprise integration patterns then Apache Camel often is my weapon of choice.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;I simply love how easy it is to set up some datasources, add some routing magic, data transformers, load balancers, content enrichers and enjoy the result.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;Another thing that I’m beginning to love is Scala and so this is the perfect time to write an article about using Scala and Apache Camel together.&lt;/p&gt;
&lt;/div&gt;</description>
    </item>
    <item>
      <title>Integration Testing IMAP, SMTP and POP3 with GreenMail</title>
      <link>https://www.hascode.com/integration-testing-imap-smtp-and-pop3-with-greenmail/</link>
      <pubDate>Mon, 30 Jul 2012 00:00:00 +0200</pubDate>
      <guid>https://www.hascode.com/integration-testing-imap-smtp-and-pop3-with-greenmail/</guid>
      <description>&lt;div id=&#34;preamble&#34;&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;Having written some e-mail handling, sending or receiving library you’d like to run some integration tests against a real mail server?&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;Then GreenMail might help you out here .. the framework is not quite new on the market but it is really easy to setup IMAP,SMTP or POP3 services with it and it comes with some helpful libraries making your life a bit easier here.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;That’s why I’ve come to the idea to share some examples for setting up different server instances, creating user accounts and – at last – fetching and validating e-mails…&lt;/p&gt;
&lt;/div&gt;</description>
    </item>
    <item>
      <title>Snippet: Simple One-Minute IMAP Client</title>
      <link>https://www.hascode.com/snippet-simple-one-minute-imap-client/</link>
      <pubDate>Sat, 03 Apr 2010 00:00:00 +0200</pubDate>
      <guid>https://www.hascode.com/snippet-simple-one-minute-imap-client/</guid>
      <description>&lt;div id=&#34;preamble&#34;&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;Building a simple IMAP Client that displays the subject of the messages in the &lt;em&gt;“inbox&lt;/em&gt;” Folder using Maven (I just like Maven).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_project_setup_maven&#34;&gt;Project Setup / Maven&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;olist arabic&#34;&gt;
&lt;ol class=&#34;arabic&#34;&gt;
&lt;li&gt;
&lt;p&gt;Create a new Maven project&lt;/p&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre class=&#34;highlight&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;mvn archetype:create -DgroupId=com.hascode.imap -DartifactId=imap-client&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Edit your &lt;em&gt;pom.xml&lt;/em&gt; and add some dependencies&lt;/p&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre class=&#34;highlight&#34;&gt;&lt;code class=&#34;language-xml&#34; data-lang=&#34;xml&#34;&gt;&amp;lt;project xmlns=&amp;#34;http://maven.apache.org/POM/4.0.0&amp;#34; xmlns:xsi=&amp;#34;http://www.w3.org/2001/XMLSchema-instance&amp;#34; xsi:schemaLocation=&amp;#34;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&amp;#34;&amp;gt;
     &amp;lt;modelVersion&amp;gt;4.0.0&amp;lt;/modelVersion&amp;gt;
     &amp;lt;groupId&amp;gt;com.hascode.imap&amp;lt;/groupId&amp;gt;
     &amp;lt;artifactId&amp;gt;imap-client&amp;lt;/artifactId&amp;gt;
     &amp;lt;version&amp;gt;0.0.1-SNAPSHOT&amp;lt;/version&amp;gt;
     &amp;lt;dependencies&amp;gt;
         &amp;lt;dependency&amp;gt;
             &amp;lt;groupId&amp;gt;junit&amp;lt;/groupId&amp;gt;
             &amp;lt;artifactId&amp;gt;junit&amp;lt;/artifactId&amp;gt;
             &amp;lt;version&amp;gt;4.8.1&amp;lt;/version&amp;gt;
         &amp;lt;/dependency&amp;gt;
         &amp;lt;dependency&amp;gt;
             &amp;lt;groupId&amp;gt;javax.mail&amp;lt;/groupId&amp;gt;
             &amp;lt;artifactId&amp;gt;mail&amp;lt;/artifactId&amp;gt;
             &amp;lt;version&amp;gt;1.4.2&amp;lt;/version&amp;gt;
         &amp;lt;/dependency&amp;gt;
     &amp;lt;/dependencies&amp;gt;
&amp;lt;/project&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_creating_the_e_mail_client&#34;&gt;Creating the E-Mail Client&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;olist arabic&#34;&gt;
&lt;ol class=&#34;arabic&#34;&gt;
&lt;li&gt;
&lt;p&gt;Create a package .. something like &lt;em&gt;com.hascode.imap.client&lt;/em&gt; ;)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create a simple mail client using &lt;em&gt;javax.mail&lt;/em&gt; in a class named &lt;em&gt;ImapClient&lt;/em&gt;&lt;/p&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre class=&#34;highlight&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;package com.hascode.imap.client;

import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Store;

public class ImapClient {
    private Session session = null;
    private Store store = null;
    private String host = null;
    private String userName = null;
    private String password = null;

    public ImapClient(String host, String userName, String password){
        this.host = host;
        this.userName = userName;
        this.password = password;
    }

    public boolean getMail() throws MessagingException {
        session = Session.getDefaultInstance(System.getProperties(),null);
        //        session.setDebug(true);
        System.out.println(&amp;#34;get store..&amp;#34;);
        store = session.getStore(&amp;#34;imaps&amp;#34;);
        System.out.println(&amp;#34;connect..&amp;#34;);
        store.connect(this.host, this.userName, this.password);
        System.out.println(&amp;#34;get default folder ..&amp;#34;);
        Folder folder = store.getDefaultFolder();
        folder = folder.getFolder(&amp;#34;inbox&amp;#34;);
        folder.open(Folder.READ_ONLY);
        System.out.println(&amp;#34;reading messages..&amp;#34;);
        Message[] messages = folder.getMessages();
        for(Message m:messages){
          System.out.println(m.getSubject());
        }
        return false;
    }
}&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;</description>
    </item>
  </channel>
</rss>
