Skip to content
Advertisement

SubEthaSMTP Unexpected error in the SMTP handler thread NoClassDefFoundError jakarta/mail/internet/AddressException

SubEthaSMTP server running fine on port 25001. After a successful authentication from my client code to Subethasmtp server i am having this error message org.subethamail.smtp.server.Session: Unexpected error in the SMTP handler thread java.lang.NoClassDefFoundError: jakarta/mail/internet/AddressException

This is my SMTPServerConfig class

JavaScript

I am using usernamepasswordvalidator

JavaScript

This is my mail client to send message to the server

JavaScript

This is the output message

JavaScript

This is my dependency

JavaScript

Advertisement

Answer

Spring Boot 2.6 and earlier still use the javax.mail namespace for JakartaMail (formerly JavaMail), while your SubEtha SMTP version seems to expect the jakarta.mail namespace. Spring Boot explicitly specifies versions of the JakartaMail package, see Spring Boot Dependency Versions and search for jakarta.mail. For Spring Boot 2.6.4, it lists version 1.6.7, and that version is still based on the javax.mail namespace.

You need to downgrade SubEtha SMTP to a version that still uses the javax.mail namespace of JakartaMail/JavaMail, and wait for Spring Boot 3 before using a version that needs the jakarta.mail namespace.

In theory, you can also set the Maven property jakarta-mail.version to 2.0.1, but this could cause problems in other parts of Spring Boot, so I do not recommend that.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement