Forum Stats

  • 3,757,567 Users
  • 2,251,246 Discussions


using imaps protocol in the database to connect to mail server

Richard Legge
Richard Legge Member Posts: 496 Silver Badge
edited Oct 13, 2021 4:05PM in JavaMail

Hi All,

Using SE 12.1,0.1.0

Im using a java stored procedure trying to connect to a mail server running imap over TLS on port 993. therefore In the code, I'm trying to set the protocol to imaps

Extract from zimbra guide:

The code is:

  Properties props = new Properties();
  props.setProperty("mail.imap.starttls.Enable", "true");
  props.setProperty("mail.imaps.socketFactory.class", "");
  props.setProperty("mail.imaps.socketFactory.fallback", "false");
  props.setProperty("mail.imaps.port", "993");
  props.setProperty("mail.imaps.socketFactory.port", "993");
  props.setProperty("", sProtocol);
  props.setProperty("mail.mime.address.strict", "false"); 
  oMailSession = Session.getInstance(props);
  oMailStore  = oMailSession.getStore();
  oMailStore.connect(sHost, 993, sUser, sPass);
  bIsConnected = true;

where sProtocol is imaps

However when I run it, I get

ORA-29532: Java call terminated by uncaught Java exception: javax.mail.NoSuchProviderException: No provider for imaps

My question is whether I can use imaps. researching, it seems you can set it in java. But I don't know whether it supported in the database. The code works OK if I connect to a pop3 server on port 110 (no SSL/TLS obviously). Also, I don't know whether whether setting the starttls is required at all?

If I try using just imap as the protocol rather than imaps (and keep starttls enabled) on port 993 get the following exception

ORA-29532: Java call terminated by uncaught Java exception: javax.mail.MessagingException: null;
 nested exception is:

I can log into the mail server using outlook using the same credentials (i.e imap, TLS/SS, 993 with the same username and password.)

Any help would be appreciated (my java is very very rusty btw)