Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

JavaMail with SSL

Posted on 2006-11-22
6
Medium Priority
?
906 Views
Last Modified: 2013-11-24
Hi,

I have a problem checking a mailbox using JavaMail API with SSL. The mail server accepts only SSL connections.

Here is the fragment of code:

Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());            
Security.setProperty("ssl.SocketFactory.provider", "DummySSLSocketFactory");
            
Properties props = new Properties();
props.setProperty("mail.imap.port", "993");
props.setProperty("mail.imap.socketFactory.port", "993");

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

store.connect(host, username, password);

When coming to the last line, the application (FastMail) is waiting for a minute and then throws a message:

javax.mail.MessagingException: ;
  nested exception is:
      java.io.IOException
      at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:441)
      at javax.mail.Service.connect(Service.java:233)
      at javax.mail.Service.connect(Service.java:134)
      at fastmail.FastMail.getMessages(FastMail.java:33)
      at fastmail.FastMail.main(FastMail.java:62)

Could you help me to debug this problem?
0
Comment
Question by:pamir
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 23

Accepted Solution

by:
Ajay-Singh earned 750 total points
ID: 17994628
add this property as well

props.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
0
 

Author Comment

by:pamir
ID: 17994967
OK added, but the result is almost the same - the application hangs up without any message at

store.connect(host, username, password);
0
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 17995039
> props.setProperty("mail.smtp.socketFactory.class",
> "javax.net.ssl.SSLSocketFactory");

sorry about typo, this should be

props.setProperty("mail.imap.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:pamir
ID: 17995196
Yes, I have already corrected the typo - the result is as I have stated above.
0
 

Author Comment

by:pamir
ID: 17996659
Oops, I have found the error! The full path to the class DummySSLSocketFactory should be pointed, including the package.

So instead of "DummySSLSocketFactory" I have put "fastmail.DummySSLSocketFactory" and everything works!
0
 

Author Comment

by:pamir
ID: 17996716
Thanks Ajay-Singh, I am giving you the points anyway since you have directed me to the right direction.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question