[Javax. Mail. nosuchproviderexception: no provider for SMTP] occurs when you send an email using javamail,
I searched the internet, mostly because the jar files such as mail. jar and activation. jar are not placed under classpath, but here I am
If you really put it under classpath, why? After debugging, you cannot solve the problem for a long time. A lot of time is wasted.
Can only start from the mail. Jar itself, use WinRAR and other open mail. jar file, in its META-INF directory folder has
[Javamail. Default. providers] file. After you open it with notepad, the following content is found:
# Javamail SMTP provider Sun Microsystems, Inc
Protocol = SMTP; type = transport; Class = com. Sun. Mail. SMTP. smtptransport; vendor = Sun Microsystems, Inc;
Protocol = smtps; type = transport; Class = com. Sun. Mail. SMTP. smtpssltransport; vendor = Sun Microsystems, Inc;
Note that SMTP in [Protocol = SMTP] is in lower case, and SMTP in the error message is in upper case. Will it be case? With such questions,
I putCodeIn the setprotocol ("SMTP") to setprotocol ("SMTP"), compile and run, and no error is reported. It is case-sensitive.
I did not expect the difference. Of course, replace Protocol = SMTP in mail. jar with protocol = SMTP, or append another one under Protocol = SMTP.
Protocol = SMTP setting is also possible (no attempt ). A very simple question has taken a lot of time and it is not worth it. I hereby write an article, so you can forget it.