1

I am using JAMES (Java Apache Mail Enterprise Server) as a mail server, and i am aiming to develop an enterprise java mailing system using Java-mail and JAF APIs on a local mail server.

For instance, i have made a simple application for test, i used the pop3 protocol to send/receive messages between clients and everything was OK. The problem which occurred is that i want to view the sent/ deleted/ trash emails for each client which is not available in pop3 protocol. I have to use IMAP in stead. But actually, the connection to the server using IMAP protocol is not working !!

this is a sample of the code :

@Stateless
public class Mailer{

@Resource(name = "mail/JavaMailSession")
private Session session

private Message[] messages;

private Message [] outboxContent(String email,String pass){
  IMAPStore store = null;
  IMAPFolder outbox = null;
  try{
  store = (IMAPStore) session.getStore("imaps");
  store.connect("localhost",-1,email,pass);
  if(store.isConnected()){
  outbox = (IMAPFolder) store.getFolder("sent-items");
  .
  .
  .

The exception is being thrown at :

 store.connect(....

The exception being thrown is :

 java.mail.MessagingException : Connection refused : connect;
 nested exception is :
 java.net.ConnectionException: Connection refused : connect

Anybody has idea about the sollution ? Thanks in advance

primeFaceUser
  • 295
  • 2
  • 15
  • Do you have IMAP enabled in the server? Have you tried connecting to it using telnet on port 143 (imap) or 993 (imaps)? – Max Sep 05 '13 at 13:29
  • IMAP is enabled by default as James server documentation says . .But when I telnet on port 143 for IMAP ---> could not open connection to the host on port 143 : connect failed. – primeFaceUser Sep 05 '13 at 15:48
  • Then it appears it is *not* enabled, or you have a firewall disabling it. – Max Sep 05 '13 at 17:51
  • This is the last telnet result : Ok serverIMAP sever ... is ready. 01 login test@localhost 123456 01 OK Login completed. That means IMAP is enabled and running ... – primeFaceUser Sep 06 '13 at 06:53
  • You are probably telnetting to port 143 (imap). Your code is configured to connect using SSL on port 993 (imaps). – Max Sep 06 '13 at 13:56

0 Answers0