problem using javamail

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

problem using javamail

Postby 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 = "mydomain.com";
String user = "test_user";
String from = "test_user@mydomain.com";
String password = "test_user";
String protocol = "pop3";
int port = -1;

Properties props = System.getProperties();
props.setProperty("mail.host", 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 + "<<<");

inbox.open(Folder.READ_WRITE);
println("Message Count:" + inbox.getMessageCount());

Message[] m = inbox.getMessages();

for (int x = 0; x < m.length; x++) {
println(m[x].getSubject());
}

inbox.close(false);
store.close();


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,com.su
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],
com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP
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/javamail.default.address.map
DEBUG: getProvider() returning javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.
POP3Store,Sun Microsystems, Inc]
Not Already Connected
DEBUG POP3: connecting to host "smashbiz.com", port 110, isSSL false
S: +OK Welcome to pop3.smashbiz.com
C: CAPA
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>>>INBOX<<<
folder URLName>>>pop3://testuser@mydomain.com/INBOX<<<
folder exists
folder type>>>1<<<
C: STAT
S: +OK 0 0
Message Count:0
C: NOOP
S: +OK
C: QUIT
S: +OK POP3 server saying goodbye...

^DooM^
Site Admin
Posts: 13853
Joined: 2005-07-29 16:18
Location: UK

Re: problem using javamail

Postby ^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! ヅ

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

Re: problem using javamail

Postby 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.

^DooM^
Site Admin
Posts: 13853
Joined: 2005-07-29 16:18
Location: UK

Re: problem using javamail

Postby ^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 testuser@mydomain.com from thunderbird / outlook and collect it again via pop3 with thunderbird / outlook.

Next send another email to testuser@mydomain.com 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! ヅ


Return to “Off-topic discussions”



Who is online

Users browsing this forum: No registered users and 3 guests