Throws javax.mail.NoSuchProviderException: smtp

Hi guys

This is my first post. I am trying to send an email using Apache commons mail in SendEmail. I have masked the SMTP server name & i am using TestEmail to pass values to it. The error doesnot show up if i comment the smail.send(). (so thats where the problem lies)

I have added the required jar files in the classpath commons-email-1.0.jar, mail.jar, activation.jar, smtp.jar

package email;

import java.util.HashMap;

import org.apache.commons.mail.*;

publicclass SendEmail{

publicboolean sendEmail(HashMap emaildetails)

{

SimpleEmail smail =new SimpleEmail();

try{

smail.setHostName("XXX.XXXX.com");

smail.addTo((String)emaildetails.get("emailto"));

smail.setFrom((String)emaildetails.get("emailfrom"));

smail.setSubject((String)emaildetails.get("emailsubject"));

smail.setMsg((String)emaildetails.get("emailmsg"));

smail.send();

}catch (EmailException e){

e.printStackTrace(System.err);

}

returntrue;

}

}

the console throws this error

org.apache.commons.mail.EmailException: Sending the email to the following server failed : XXX.XXXX.com:25

at org.apache.commons.mail.Email.sendMimeMessage(Email.java:873)

at org.apache.commons.mail.Email.send(Email.java:898)

at email.SendEmail.sendEmail(SendEmail.java:25)

at email.TestEmail.main(TestEmail.java:32)

Caused by: javax.mail.NoSuchProviderException: smtp

at javax.mail.Session.getService(Session.java:611)

at javax.mail.Session.getTransport(Session.java:541)

at javax.mail.Session.getTransport(Session.java:484)

at javax.mail.Session.getTransport(Session.java:464)

at javax.mail.Session.getTransport(Session.java:519)

at javax.mail.Transport.send0(Transport.java:155)

at javax.mail.Transport.send(Transport.java:81)

at org.apache.commons.mail.Email.sendMimeMessage(Email.java:863)

... 3 more

i had problems with the jar files not being compatible with the latest commons email jar files,so i replaced the following jar files:- mail.jar, activation.jar, smtp.jar with the previous versions thats how i got this far. All help will be appreciated

[2984 byte] By [vinukhoslaa] at [2007-11-26 17:56:46]
# 1
As explained in the JavaMail NOTES.txt file, you don't need bothmail.jar and smtp.jar. Remove smtp.jar and see if it works.(Why exactly that would cause it to fail, I don't know.)What version of the JDK are you using?
bshannona at 2007-7-9 5:10:00 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
I will remove the smtp.jar file on lip directory but i got the same error on"javax.mail.NoSuchProviderException: smtp" .plz any idea for this problem
errrora at 2007-7-9 5:10:00 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3
Most likely there's something wrong in your CLASSPATH.Check to make sure you only have one copy of mail.jar.Set the System property "mail.debug" to "true". The debugoutput might provide more clues as to what's going wrong.
bshannona at 2007-7-9 5:10:00 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4
I got the same problem "javax.mail.NoSuchProviderException: smtp" on Linux server.but this program running proper in local server(Apache). Do any modification on program or any .jar file load on the Linux server. everbody give the solution
errrora at 2007-7-9 5:10:00 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 5
Something is wrong with your configuration. Do as I suggested in myprevious message to debug it.
bshannona at 2007-7-9 5:10:00 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 6

Hi

Are you using this within a tomcat application?

If so I had the same problem providing it isn't the actual server - the problem I had was that I had the mail.jar within my /shared/lib directory of tomcat and ALSO had it on my build path of my java project and the two were getting confused if you like.

I simply took it off my buildpath for the java project and it was sorted?!

Let me know how you get on

jimbobegga at 2007-7-9 5:10:00 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...