Seam Mail 3.1.1.Final Released

I’m happy to announce that I’ve released a minor update to Seam 3 Mail versioned 3.1.1.Final. This is a minor release which is compatible with Seam 3.1.0.Final.

Whats new?

The main goal of this release was to fill in some gaps in documentation as well as some minor bug fixes which popped up since the 3.1.0.Final release. I’ve also added in a utility class called MessageConverter which allows you to read a MimeMessage back into the internal EmailMessage object used by Seam Mail. This opens up the option for Seam Mail to receive messages in addition to sending them. Check out Closed Issues on the JIRA tracker for details.

What does future look like?

Seam 3 Mail will continue to provide releases in its current format until the time comes for it to transition to Apache DeltaSpike. In the meantime if you have features for fixes to contribute just open a JIRA and I’ll be happy to work them in.

How about an example?

POP3+SSL to receive an MimeMessage and convert it. It’s basically for gmail but with values changed to protect the innocent.

import java.util.Properties;

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

import org.jboss.seam.mail.core.EmailMessage;
import org.jboss.seam.mail.util.MessageConverter;

import com.sun.mail.pop3.POP3SSLStore;

public class Popper {

    public static void main(String[] args) throws Exception {

        String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";

        Properties pop3Props = new Properties();

         pop3Props.setProperty("mail.pop3.socketFactory.class", SSL_FACTORY);
         pop3Props.setProperty("mail.pop3.socketFactory.fallback", "false");
         pop3Props.setProperty("mail.pop3.port", "995");
         pop3Props.setProperty("mail.pop3.socketFactory.port", "995");

         URLName url = new URLName("pop3", "pop.example.com", 995, "", "foo@example.com", "mypass");

         Session session = Session.getInstance(pop3Props, null);
         Store store = new POP3SSLStore(session, url);
         store.connect();

         Folder inbox = store.getFolder("INBOX");
         inbox.open(Folder.READ_ONLY);

         Message[] messages = inbox.getMessages();

         if (messages.length == 0) {
             System.out.println("No Messages Found");
         }

         List<EmailMessage> emailMessages = new ArrayList<EmailMessage>();

         for (Message m : messages) {
             emailMessages.add(MessageConverter.convert(m));
         }

         inbox.close(false);
         store.close();
    }
}
tags: java seam email
Cody Lerum - July 15, 2012
About outjected.com

Outjected is an infrequent blog about the frequent issues and annoyances that pop up while coding.

These are living posts and will be updated as errors or improvements are found.
About Me
Google+