hi guys,
as stated in the title, i have problem when sending email using javax mail through a secure smtp server.
if i try to send email to my company smtp, my code will run perfectly. but when using secure smtp i have to add this code :
properties.setProperty("mail.smtp.starttls.enable", "true");
if i don't, then it will give an error :
javax.mail.MessagingException: [EOF]
after add this properties.setProperty("mail.smtp.starttls.enable", "true"); it throwing another error :
javax.mail.MessagingException: Can't send command to SMTP host;
nested exception is:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
so i added the smtp certificate to my keystore. i add it to the both JRE and JDK folder. for the add certificate tutorial i utilize InstallCert.java file from this tutorial http://www.mkyong.com/webservices/jax-ws/suncertpathbuilderexception-unable-to-find-valid-certification-path-to-requested-target/
i have follow this tutorial until the last step which i have to execute the class again and then in command prompt it will prompt a success message "No errors, certificate is already trusted".
i have re-check my keystore whether it already listed with my certificate or not, using this command keytool -list -keystore jssecacerts.
i checked it for the both folder (JDK & JRE) and they have listed.
i also have try to remove the cacert file (relocate it to another folder)
but still i'm having sslHandshakeexception. anyone have experience this ? which JVM my jdev will be using ? JDK / JRE ? or jdev have another standalone jvm that i have to store the certificate too ?
another confusion is when i try to SSLPoke to that server with port 25, it throwing this error : javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
my additional note is, i get this attachment from a https, that is the web mail for that smtp. how can i know that's the right certificate for that smtp ?
pls throw some enlightement..
thanks