Development log: javax. Mail. nosuchproviderexception: no provider for SMTP

Source: Internet
Author: User
  

[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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.