Search code examples
javalinuxemailzimbra

Java Mail client not working on Linux


I have an email ssl client for zimbra mail server that work perfectly on windows but i got a failure authentication on linux, i had verified that all that network conf. dns, port and firewall are correct

the properties for session:

props.put("mail.smtps.host", "my.mail.server");
props.put("mail.smtps.host", "my.mail.server");
props.put("mail.smtps.starttls.enable", "true");
props.put("mail.smtps.port", "465");
props.put("mail.smtps.auth", "true");
props.put("mail.smtps.ssl.trust", "my.mail.server");

Getting the session:

Session session = Session.getDefaultInstance(props);

Transport :

Transport t = session.getTransport("smtps");
t.connect("user", "pass");
t.sendMessage(message, message.getAllRecipients());

something that got my attention when using debug, is the postfix response in the message

Windows Debug Log:

DEBUG: setDebug: JavaMail version 1.4.3 DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc] DEBUG SMTP: useEhlo true, useAuth true DEBUG SMTP: trying to connect to host "my.mail.server", port 465, isSSL true 220 my.mail.server ESMTP ready. DEBUG SMTP: connected to host "my.mail.server", port: 465

meanwhile on Linux i got this:

DEBUG: setDebug: JavaMail version 1.4.3 DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc] DEBUG SMTP: useEhlo true, useAuth true DEBUG SMTP: trying to connect to host "my.mail.server", port 465, isSSL true 220 my.mail.server ESMTP Postfix DEBUG SMTP: connected to host "my.mail.server", port: 465

i would appreciate any help.


Solution

  • I have found the issue, the server auth was different for local and external access, for development we were using a windows server outside the net, and linux server for intranet.

    In fact, it was a misconfiguration on mail server

    The java mail client remains the same now for local and public access.