The com.sun.mail package is unavailable

Previously the com.sun.mail reference implementation package was provided as third-party API by the JavaMail 1.5, JavaMail 1.6, and Jakarta Mail 2.0 features. The Jakarta Mail specification API has now been split from the API of the reference implementation. Remove the usage of com.sun.mail packages from your application.

This rule is flagged once per Java class.

For users of the com.sun.mail encoder and decoder classes, to help facilitate this change Jakarta Mail 2.1 introduces the jakarta.mail.util.StreamProvider utility interface, which can be easily obtained with the jakarta.mail.Session.getStreamProvider() method. You can then use the StreamProvider instance to obtain encoded/decoded streams for the encoding/decoding methods that Jakarta Mail 2.1 supports.

The recommended replacement jakarta.mail.util.StreamProvider methods for the com.sun.mail encoder and decoder classes are:

For more Jakarta 10 migration information, see Differences between Jakarta Mail 2.1 and 2.0.

Also, see the blog introducing Jakarta Mail 2.1 in Open Liberty and the Jakarta Mail 2.1 Javadoc.