problem using javamail

Forum for things that doesn't really have anything to do with hMailServer. Such as php.ini, beer, etc etc.
Post Reply
New user
New user
Posts: 2
Joined: 2010-11-24 18:16

problem using javamail

Post by bclerico » 2010-11-24 18:24

I have successfully setup hmailserver in a lab environment. I can connect using Outlook and can send and receive emails. The problem I am having is that when I connect with a simple Java program using javamail, the INBOX count is always zero regardless of which user I connect with. There are definitely messages in the inbox - I can see them when using my Outlook client. Any help would be greatly appreciated. Code and debug is here:

import java.util.*;
import javax.mail.*;
import javax.mail.event.*;
import javax.mail.internet.*;
import javax.activation.*;

String host = "";
String user = "test_user";
String from = "";
String password = "test_user";
String protocol = "pop3";
int port = -1;

Properties props = System.getProperties();
props.setProperty("", host);
props.setProperty("mail.user", user);
props.setProperty("mail.from", user);
props.setProperty("mail.debug", "true");

Session session = Session.getInstance(props, null);
Store store = session.getStore(protocol);

println((store.isConnected())?"Already Connected":"Not Already Connected");

store.connect(host, port, user, password);

Folder inbox = store.getFolder("INBOX");
println("folder>>>" + inbox.getFullName() + "<<<");
println("folder URLName>>>" + inbox.getURLName() + "<<<");
println((inbox.exists()?"folder exists":"folder does not exist"));

int folderType = inbox.getType();
println("folder type>>>" + folderType + "<<<");;
println("Message Count:" + inbox.getMessageCount());

Message[] m = inbox.getMessages();

for (int x = 0; x < m.length; x++) {


DEBUG info:

C:\groovy\working>run readmail
DEBUG: JavaMail version 1.4.3
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax
.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsyste
ms, Inc], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com
.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPSSLSt
ore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsyst
ems, Inc], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,
n.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=jav
ax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc],
3Store,Sun Microsystems, Inc]}
DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.
sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], imap=javax.mail.Provider[STOR
E,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], smtps=javax.mail.Prov
ider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc],
pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems
, Inc], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun
Microsystems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.S
MTPTransport,Sun Microsystems, Inc]}
DEBUG: successfully loaded resource: /META-INF/
DEBUG: getProvider() returning javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.
POP3Store,Sun Microsystems, Inc]
Not Already Connected
DEBUG POP3: connecting to host "", port 110, isSSL false
S: +OK Welcome to
S: -ERR Invalid command in current state.
C: USER test_user
S: +OK Send your password
C: PASS test_user
S: +OK Mailbox locked and ready
folder URLName>>>pop3://<<<
folder exists
folder type>>>1<<<
S: +OK 0 0
Message Count:0
S: +OK
S: +OK POP3 server saying goodbye...

Site Admin
Posts: 13862
Joined: 2005-07-29 16:18
Location: UK

Re: problem using javamail

Post by ^DooM^ » 2010-11-24 20:45

As hMail is working correctly, I suggest you contact javamail support to find out what's wrong with it.
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

New user
New user
Posts: 2
Joined: 2010-11-24 18:16

Re: problem using javamail

Post by bclerico » 2010-11-24 21:26

I am chasing it from the javamail side as well, however, I was hoping to find someone on this forum that has experience with javamail and hmailserver.

Site Admin
Posts: 13862
Joined: 2005-07-29 16:18
Location: UK

Re: problem using javamail

Post by ^DooM^ » 2010-11-24 21:31

Here is what I suggest you do then to maybe see what's going on yourself.

Enable SMTP and POP3 logging.

Send an email to from thunderbird / outlook and collect it again via pop3 with thunderbird / outlook.

Next send another email to with thunderbird / outlook then close the mail client.

Run your java app.

Compare the two log sessions and see what javamail did differently.
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

Post Reply