Re: Can't connect with JavaMail even though Thunderbird works
On 05/10/10 21:50, Gary wrote:
I am trying to connect to our own mail server (Ubuntu, dovecot,
postfix) and, started by connecting to GMail as a test. I finally got
that to work and modified the code to work with our own server. Even
though Thunderbird connects regularly using port 993 with unencrypted
authentication,
I would be surprised if Thunderbird was attempting unencrypted
connections on port 993, or that your IMAP server was accepting them.
You would have to manually tweak a few things to get unencrypted IMAP on
port 993. The default would be SSL on that port as port 993 is defined
by IANA as the port for imaps, i.e. IMAP using SSL on connect. Are you
sure you are not referring to the Thunderbird option "Use secure
authentication", which is something else entirely. If SSL/TLS is
selected in the connection security drop-box then Thunderbird is using SSL.
If you want to use unencrypted IMAP the usual port is 143. That should
be the default in JavaMail if you don't specify the server port.
when i try to connect with JavaMail there is no
response from the server and the code just waits for return from the
store.connect method. As a test, I turned off firewalls at both client
and server ends which did not help. Here is the core of the code:
**********************
Properties props = new Properties();
session = Session.getDefaultInstance(props, null);
Store store = session.getStore("imap");
store.connect(serverName, 993, userName, password);
************************
If I try connecting with imaps, I get a "PKIX path building failed:"
exception since I have not imported the required certificate. But
using imaps should not be necessary because Thunderbird does
unencrypted authentication and does not have a certificate either, so
it seems like I should be able to get JavaMail to work without a
certificate the way Thunderbird works without a certificate.
The client only needs a cert. if the cert. used by the server is signed
by an unknown CA, usually due to using a self-signed cert. or defining
your own CA. In that case both Thunderbird and Java would require the CA
cert in order to verify the server cert. The server cert. is sent by the
server during the initial SSL handshake.
--
Nigel Wade