File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other JSE/JEE APIs and the fly likes Sending email in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Sending email in jsp" Watch "Sending email in jsp" New topic

Sending email in jsp

Mike Schultz

Joined: Dec 14, 2004
Posts: 3
I need help in sending email in jsp. I've been using JavaMail, and I edited this code snippet from
into this:


import javax.mail.*;
import javax.mail.internet.*;

import java.util.Properties;

public class SimpleMail {
public static void main(String[] args) throws Exception{
Properties props = new Properties();
props.setProperty("mail.transport.protocol", "");
props.setProperty("", "");
props.setProperty("mail.user", "my_username");
props.setProperty("mail.password", "my_password");

Session mailSession = Session.getDefaultInstance(props, null);
Transport transport = mailSession.getTransport();

MimeMessage message = new MimeMessage(mailSession);
message.setContent("This is a test", "text/plain");
message.addRecipient(Message.RecipientType.TO, new InternetAddress(""));



However, when I compile and run it, it says:
Exception in thread "main" javax.mail.NoSuchProviderException: No provider for at javax.mail.Session.getProvider( at javax.mail.Session.getTransport( at javax.mail.Session.getTransport( at javax.mail.Session.getTransport( at SimpleMail.main(

Can anyone please help me? It's for a project, and it's quite urgent. ><
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63870

Sicne this is pretty much JSP-independent, I'm moving it to the "other APIs" forum where JavaMail is usually discussed.

[Asking smart questions] [About Bear] [Books by Bear]
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

You are configuring JavaMail to use a protocol called "" which doesn't exist. However, SMTP does.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
I agree. Here's the link:
subject: Sending email in jsp
It's not a secret anymore!