javax.mail.NoSuchProviderException: No provider for smtps

后端 未结 9 1392
离开以前
离开以前 2020-12-11 16:14

I\'m trying to set up my Java project to be able to send e-mail (via g-mail, if it matters) and am getting \"javax.mail.NoSuchProviderException: No provider for smtps\" ever

相关标签:
9条回答
  • 2020-12-11 16:49

    So it turns out that the issue was that an outdated version of mail.jar was included in a project that I was referencing and, upon updating that copy of the mail.jar, the issue was resolved.

    For future reference, is there any way to log or provide visibility on such jar conflicts?

    https://confluence.atlassian.com/confkb/cannot-send-email-due-to-javax-mail-nosuchproviderexception-smtp-error-154079.html

    0 讨论(0)
  • 2020-12-11 16:53

    Just in case anyone makes the same mistake as I have: you have to use lowercase letters for the protocol resolving to work. If you type SMTP as a protocol name instead of smtp you will get the NoSuchProviderException. It most likely works the same way for all other providers.

    0 讨论(0)
  • 2020-12-11 17:00

    JavaMail asks the ClassLoader for the configuration file that configures the protocol providers. If the ClassLoader doesn't work correctly, JavaMail won't be able to find the configuration file. There's an incompatibility between the way the OSGi ClassLoaders work and what JavaMail expects, which can cause this problem. If you're running your application in Eclipse itself, that might explain this problem. Another common cause of this problem is importing the mail.jar file into your project in such a way that the class files are extracted from the jar file and included in your application, but the configuration files are left behind.

    Try running your program from the command line using the "java" command and with the mail.jar file in your CLASSPATH.

    0 讨论(0)
提交回复
热议问题