Article Image


For some ongoing development projects I needed a reliable email server and decided to go for the T-Online mail infrastructure.

Sending emails via java seemed to easy using the great JAVAMAIL implementation, however the STARTTLS feature resulted in some messy testing times.

Going for the real solution code...

Properties props = new Properties();
props.put("" , "");
props.put("mail.imap.user" , USERNAME);
props.put("mail.imap.ssl.enable", "true");

// Start SSL connection

props.put("mail.imap.socketFactory" , "993" );
props.put("mail.imap.socketFactory.class" , "" );
props.put("mail.imap.port" , "993");

Session session = Session.getDefaultInstance(props , new Authenticator() {
    protected PasswordAuthentication getPasswordAuthentication() {
        return new PasswordAuthentication( USERNAE , PASSWORD);

Store store  = session.getStore("imap");
store.connect("" , USERNAME , PASSWORD);
Folder folder = store.getFolder("INBOX");;
int count = folder.getMessageCount();

Blog Logo

Markus Schmall



Homepage of Markus 'Flake' Schmall

A Jekyll theme - Medium inspired

Back to Overview