javax.mail.NoSuchProviderException: No provider for smtp
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   robert_luo
Posted On:   Wednesday, June 6, 2001 05:58 AM

Hi All, I've got a problem sending email via smtp using tomcat3.2.1 and jdk1.2.2. The code works fine with Javawebserver2.0 and iPlanet webserver. But when I migrate it to tomcat, I got the following error message. javax.mail.NoSuchProviderException: No provider for smtp. can anybody give a hand on how to overcome such a problem? The jsp code is as following: <%@ page import="java.sql.*, database.*, java.io.*, java.net.*, java.util.*, javax.mail.*, javax.mail.internet.*, javax.activation.*" %> <% /* some irrelevant codes here ommitted */ // we're using SMTP /* assume the message msgText, from and to address already constructed */ Strin   More>>

Hi All,
I've got a problem sending email via smtp using tomcat3.2.1 and jdk1.2.2.
The code works fine with Javawebserver2.0 and iPlanet webserver. But when I migrate it to tomcat, I got the following error message.
javax.mail.NoSuchProviderException: No provider for smtp.

can anybody give a hand on how to overcome such a problem? The jsp code is as following:

<%@ page import="java.sql.*, database.*, java.io.*, java.net.*, java.util.*, javax.mail.*, javax.mail.internet.*, javax.activation.*" %>

<%
/* some irrelevant codes here ommitted */

// we're using SMTP
/* assume the message msgText, from and to address already constructed
*/

String mailhost = "smtp.convoke.com";
String mailer = "msgsend";
boolean debug = false;
Properties props = new Properties();
props.put("mail.smtp.host",mailhost);

//get an session object
javax.mail.Session ss = Session.getDefaultInstance(props, null);
ss.setDebug(debug);

Message msg = new MimeMessage(ss);
msg.setFrom(new InternetAddress(from));
msg.setSubject(subject);
msg.setSentDate(new java.util.Date());

msg.setContent(msgText,"text/html");
msg.setText(msgText);
msg.saveChanges();

//recipients
InternetAddress[] recipients={new InternetAddress("zl3@hotmail.com")};

Transport t=ss.getTransport("smtp");
t.connect();
t.sendMessage(msg, recipients);
t.close();

%>

   <<Less

Re: javax.mail.NoSuchProviderException: No provider for smtp

Posted By:   John_Zukowski  
Posted On:   Wednesday, June 6, 2001 08:41 AM

It sounds like you didn't install the complete JavaMail classes but only pulled over the partial .jar file. As already answered, if you are using JavaMail 1.2, you need to use either mail.jar for all providers or the protocol specific set if you don't want all protocols supported.
About | Sitemap | Contact