Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception in the mail servlet

 
Venkatachalapathi Madhes
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried out the following mail servlet .
I got the exception NosuchProvider Exception
What I have to do?
I am using VisualAge.
How can solve this probelm
import javax.mail.internet.*;
import javax.mail.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class email extends HttpServlet
{

String smtphost;
public void doGet(javax.servlet.http.HttpServletRequest request,javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
{
mailsend();
}
public void mailsend()
{
try
{
java.util.Properties pro = System.getProperties();

pro.put("mail.smtp.host","matsystems");
pro.put("mail.transport.protocol","smtp");
//get the Session object to get control over service providers
Session ses = Session.getInstance(pro,null);
//create new message
Message mess = new MimeMessage(ses);


mess.setFrom(new InternetAddress("venhur@usa.net"));


mess.addRecipient(Message.RecipientType.TO, new InternetAddress("venhur100@yahoo.co.uk"));
System.out.println("to");

mess.setSubject("Hai");

mess.setText("pathi testing mail servlet");

System.out.println("Message over");

//Transport t = ses.getTransport("SMTP_MAIL");
//t.connect("matsystems","venhur@usa.net","ven100");
//t.send(mess);
//t.connect();
Transport.send(mess);

}
catch(AddressException ade)
{
System.out.println("Address exception");

}
catch(SendFailedException sfe)
{
System.out.println("send failed exception");

}
catch(NoSuchProviderException nop)
{
System.out.println("No such provider");
}
catch(MessagingException me)
{
System.out.println("messaging exception");

}


}
public void init(ServletConfig conf) throws javax.servlet.ServletException
{

super.init(conf);
smtphost=conf.getInitParameter("matsystems");

}

}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic