Skip to content

Do we have example of using sslcontext-kickstart as SSLSocketFactory for javax.mail #321

Answered by skarzhevskyy
skarzhevskyy asked this question in Q&A
Discussion options

You must be logged in to vote

Good Point.
Yes it does work as expected.

  • If you do not supply "mail.smtp.socketFactory" java mail will use default system settings and certificates...
  • If you give it mail.smtp.socketFactory than it is used and jvm system settings does not mater.

The code above also have a mistake .
If you intend to use SSL ports and omit 'mail.smtp.socketFactory' it will hangs ... And setting connection timeouts will not help.
So for clarity proper code should set this

props.put("mail.smtp.ssl.enable", "true");

This version looks cleaner.

import java.nio.file.Paths;
import java.time.Duration;
import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.ma…

Replies: 4 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Hakky54
Comment options

Comment options

You must be logged in to vote
1 reply
@Hakky54
Comment options

Answer selected by Hakky54
Comment options

You must be logged in to vote
1 reply
@Hakky54
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants