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
try
Transport transport = session.getTransport("smtp");
for the benefit of others with a similar problem as I had.
make sure you remember to set
properties.put("mail.transport.protocol", "smtp"));
instead of
properties.put("mail.transport.protocol", "SMTP"));
I got the same issue. i resolved it by adding the correct dependency in maven. group id - javax.mail artifactory - mail version 1.4.7
if you are doing, without maven build, add the correct library for javax.mail
Make sure that you have the javax.mail.jar in you build path. If you are using eclipse you may have to refresh or right click your project in the files explorer, select configure build path, add external JAR and then add it to the build path. Send email using java gives working code (I've tested it) in case you just want to look over yours. If that is not the problem, or you are not using eclipse, a stack trace would be nice
I had mail.jar and activation.jar in tomcat's lib directory and mailapi.jar in application's lib directory. Application was reading mailapi.jar during runtime, since mailapi.jar is light weight version of mailing api and it needs smtp.jar that why application was throwing smtp exception. So, if you want to get rid of this exception,
Please resolve conflict between mail.jar and mailapi.jar by:
(FYI: I searched file system to find out mail related jar files and got to know that I have conflicting jar file in the following path (added by gradle in classpath) C:\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\testapp\WEB-INF\lib)
When you use Mail API make sure that which protocol are you expecting to work with? In this case you are missing smtp.jar with your eclipse project.
there are several jars for different protocols are available in mail api. EX: dsn.jar , gimap.jar , imap.jar ,mailapi.jar ,pop3.jar ,smtp.jar