NoSuchProviderException

          I am getting the following error when I am trying to send
          messages using Transport.send(msg)
          javax.mail.NoSuchProviderException: No provider for Address
          type:rfc822
          at javax.mail.Session.getTransport(Session.java:475)
               at javax.mail.Transport.send0(Transport.java:154)
               at javax.mail.Transport.send(Transport.java:80)
               at fictx.WebServices.doSendMessage(WebServices.java:177)
               at fictx.WebServices.doPost(WebServices.java:87)
               at javax.servlet.http.HttpServlet.service
          (HttpServlet.java:772)
               at javax.servlet.http.HttpServlet.service
          (HttpServlet.java:865)
               at
          weblogic.servlet.internal.ServletStubImpl.invokeServlet
          (ServletStubImpl.java, Compiled Code)
               at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java,
          Compiled Code)
               at weblogic.servlet.internal.ServletContextImpl.invokeServlet
          (ServletContextImpl.java, Compiled Code)
               at weblogic.servlet.internal.ServletContextManager.invokeServlet
          (ServletContextManager.java, Compiled Code)
               at weblogic.socket.MuxableSocketHTTP.invokeServlet
          (MuxableSocketHTTP.java, Compiled Code)
               at weblogic.socket.MuxableSocketHTTP.execute
          (MuxableSocketHTTP.java, Compiled Code)
               at weblogic.kernel.ExecuteThread.run(ExecuteThread.java,
          Compiled Code)
          I am using Weblogic 5.1 server and used JavaMailAPI.I have
          included mail.jar and activation.jar paths in the CLASSPATH
          variable.
          Can anyone help me figure out where the problem is.
          Thanks for any help.
          

Make sure you add the following lines in your code:
          // Get system properties
          Properties props = System.getProperties();
          // Setup mail server
          props.put("mail.smtp.host", host);
          // Get session
          Session session = Session.getInstance(props, null);
          If you use any other protocol other than smtp you need to include the corresponding jar file.
          Thanks,
          Kumar.
          Mike Reiche wrote:
          > Try putting mail.jar and activation.jar at the beginning
          > of your classpath.
          >
          > Mike
          >
          > "Latha Pusapaty" <[email protected]> wrote:
          > >
          > >I am getting the following error when I am trying to send
          > >
          > >messages using Transport.send(msg)
          > >javax.mail.NoSuchProviderException: No provider for Address
          > >type:rfc822
          > > at javax.mail.Session.getTransport(Session.java:475)
          > > at javax.mail.Transport.send0(Transport.java:154)
          > > at javax.mail.Transport.send(Transport.java:80)
          > > at fictx.WebServices.doSendMessage(WebServices.java:177)
          > > at fictx.WebServices.doPost(WebServices.java:87)
          > > at javax.servlet.http.HttpServlet.service
          > >(HttpServlet.java:772)
          > > at javax.servlet.http.HttpServlet.service
          > >(HttpServlet.java:865)
          > > at
          > >weblogic.servlet.internal.ServletStubImpl.invokeServlet
          > >(ServletStubImpl.java, Compiled Code)
          > > at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java,
          > >Compiled Code)
          > > at weblogic.servlet.internal.ServletContextImpl.invokeServlet
          > >(ServletContextImpl.java, Compiled Code)
          > > at weblogic.servlet.internal.ServletContextManager.invokeServlet
          > >(ServletContextManager.java, Compiled Code)
          > > at weblogic.socket.MuxableSocketHTTP.invokeServlet
          > >(MuxableSocketHTTP.java, Compiled Code)
          > > at weblogic.socket.MuxableSocketHTTP.execute
          > >(MuxableSocketHTTP.java, Compiled Code)
          > > at weblogic.kernel.ExecuteThread.run(ExecuteThread.java,
          > >Compiled Code)
          > >
          > > I am using Weblogic 5.1 server and used JavaMailAPI.I
          > >have
          > >included mail.jar and activation.jar paths in the CLASSPATH
          > >
          > >variable.
          > >Can anyone help me figure out where the problem is.
          > >Thanks for any help.
          > >
          > >
          

Similar Messages

  • Exception in thread "main" javax.mail.NoSuchProviderException: invalid prov

    HI,
    I am trying to read mails from my inbox i amgetting the ErrorC:\javamail>java
    Readmail
    Exception in thread "main" javax.mail.NoSuchProviderException: No provider for IMAP
            at javax.mail.Session.getProvider(Session.java:455)
            at javax.mail.Session.getStore(Session.java:530)
            at javax.mail.Session.getStore(Session.java:510)
            at Readmail.main(Readmail.java:24)My Code is    {
    String host = "hostname";
    String username = "user";
    String password = "password";
    // Create empty properties
    Properties props = new Properties();
    // Get session
    Session session = Session.getDefaultInstance(props,null);
    // Get the store
    Store store = session.getStore("IMAP");
    store.connect(host, username, password);
    // Get folder
    Folder folder = store.getFolder("Inbox");
    folder.open(Folder.READ_ONLY);
    // Get directory
    Message message[] = folder.getMessages();
    for (int i=0, n=message.length; i<n; i++)
       System.out.println(i + ": " + message.getFrom()[0]
    + "\t" + message[i].getSubject());
    // Close connection
    folder.close(false);
    store.close();
    I have also tried POP3 and MIME and SMTP
    Can anyone help me Thanks

    hi bshannon,
    I am getting the same error for others but for pop3 the error is as below
    Exception in thread "main" javax.mail.MessagingException: Connect failed;
      nested exception is:
            java.net.ConnectException: Connection refused: connect
            at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:148)
            at javax.mail.Service.connect(Service.java:275)
            at javax.mail.Service.connect(Service.java:156)
            at Readmail.main(Readmail.java:25)
    Caused by: java.net.ConnectException: Connection refused: connect
            at java.net.PlainSocketImpl.socketConnect(Native Method)
            at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
            at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
            at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
            at java.net.Socket.connect(Socket.java:452)
            at java.net.Socket.connect(Socket.java:402)
            at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:232)
            at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
            at com.sun.mail.pop3.Protocol.<init>(Protocol.java:81)
            at com.sun.mail.pop3.POP3Store.getPort(POP3Store.java:201)
            at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:144)
            ... 3 more

  • Javax.mail.NoSuchProviderException: No provider for Address type: rfc822

    Use JavaMail 1.2 send Mail Errors:
    "javax.mail.NoSuchProviderException: No provider for Address type: rfc822"
    Why?
    Can you supply a stmp server name?
    Thanks.

    [skyask],
    Honestly, I am not very sure where the JVM is located for the WebLogic 5.1 application server. You probably need to contact your local BEA rep office for support.
    The jar file for the JavaMail API is either mail.jar (contains the API libraries) or mailapi.jar (contains the API libraries and all the providers), so I guess if you search the WebLogic directories, you might be able to locate it.
    It also depends on the OS platform that you are working on and the WebLogic installation documentation may give a clue or two where the .jar files for optional Java packages are found.
    HTH.
    Allen Lai
    Developer Technical Support
    SUN Microsystems
    http://www.sun.com/developers/support/

  • Javax.mail.NoSuchProviderException: No provider for SMTP

    whats the meaning of the following exception javax.mail.NoSuchProviderException: No provider for SMTP
    can any one help.
    thanks and regards.

    This exception is thrown when Session attempts to instantiate a Provider (e.g. (com.sun.mail.smtp.SMTPTransport)) that doesn't exist.
    Check if the smtp.jar is in the classpath.

  • Javax.mail.NoSuchProviderException: No provider for ifs1

    Similar to the question found in William Troper's thread run on
    November 1. We had mail code working fine, changed some
    variables to incorporate a migratable build and have now lost
    our mail functionality.
    We have followed William's advice by renaming all of Sun's Mail
    classes in the ~\9ifs\settings\META-INF directory and still no
    joy.
    Does anyone have any ideas of what is causing a "No provider for
    ifs1" error message?
    Cheers,
    Susan

    Hi Scott,
    These (among other) items are in my CLASSPATH (printed out at
    runtime)
    /projects/intranet/lib/mail.jar:/app/oracle/product/9.0.1S/9ifs/s
    ettings/META-INF:
    Here is my stack. Also, the code is EXACLTY the same between
    what was working and what is now not. Thanks for looking in to
    this:
    javax.mail.NoSuchProviderException: No provider for ifs1
         at javax.mail.Session.getProvider(Session.java:249)
         at javax.mail.Session.getTransport(Session.java:442)
         at javax.mail.Session.getTransport(Session.java:423)
         at com.mim.intranet.utils.MessageFactory.sendMesg
    (MessageFactory.java:130)
         at
    com.mim.intranet.unittest.utils.MessagingUT.testValidMesg
    (MessagingUT.java:56)
         at java.lang.reflect.Method.invoke(Native Method)
         at junit.framework.TestCase.runTest(TestCase.java:166)
         at junit.framework.TestCase.runBare(TestCase.java:140)
         at junit.framework.TestResult$1.protect
    (TestResult.java:106)
         at junit.framework.TestResult.runProtected
    (TestResult.java:124)
         at junit.framework.TestResult.run(TestResult.java:109)
         at junit.framework.TestCase.run(TestCase.java:131)
         at junit.framework.TestSuite.runTest(TestSuite.java:173)
         at junit.framework.TestSuite.run(TestSuite.java:168)
         at junit.framework.TestSuite.runTest(TestSuite.java:173)
         at junit.framework.TestSuite.run(TestSuite.java:168)
         at junit.textui.TestRunner.doRun(TestRunner.java:74)
         at junit.textui.TestRunner.run(TestRunner.java:200)
         at com.mim.intranet.unittest.AllTests.main
    (AllTests.java:40)
    4887 [main] WARN com.mim.intranet.unittest.utils.MessagingUT -
    Sending Exception
    F
    Time: 4.898
    There was 1 failure:
    1) testValidMesg(com.mim.intranet.unittest.utils.MessagingUT)
    junit.framework.AssertionFailedError: Failed sending message :
    com.mim.intranet.exception.IntranetException: Failed sending
    message encountered unexpected exception
    Wrapped Exception is : javax.mail.NoSuchProviderException: No
    provider for ifs1
         at
    com.mim.intranet.unittest.utils.MessagingUT.testValidMesg
    (MessagingUT.java:63)
         at com.mim.intranet.unittest.AllTests.main
    (AllTests.java:40)
    FAILURES!!!
    Tests run: 1, Failures: 1, Errors: 0
    com.mim.intranet.exception.IntranetException: Failed sending
    message encountered unexpected exception
    Wrapped Exception is : javax.mail.NoSuchProviderException: No
    provider for ifs1
         at com.mim.intranet.utils.MessageFactory.sendMesg
    (MessageFactory.java:187)
         at
    com.mim.intranet.unittest.utils.MessagingUT.testValidMesg
    (MessagingUT.java:56)
         at java.lang.reflect.Method.invoke(Native Method)
         at junit.framework.TestCase.runTest(TestCase.java:166)
         at junit.framework.TestCase.runBare(TestCase.java:140)
         at junit.framework.TestResult$1.protect
    (TestResult.java:106)
         at junit.framework.TestResult.runProtected
    (TestResult.java:124)
         at junit.framework.TestResult.run(TestResult.java:109)
         at junit.framework.TestCase.run(TestCase.java:131)
         at junit.framework.TestSuite.runTest(TestSuite.java:173)
         at junit.framework.TestSuite.run(TestSuite.java:168)
         at junit.framework.TestSuite.runTest(TestSuite.java:173)
         at junit.framework.TestSuite.run(TestSuite.java:168)
         at junit.textui.TestRunner.doRun(TestRunner.java:74)
         at junit.textui.TestRunner.run(TestRunner.java:200)
         at com.mim.intranet.unittest.AllTests.main
    (AllTests.java:40)
    -----------------------------------------------------------------

  • NoSuchProviderException  usingTomcat

    I am trying to send an email from an app developed with Struts and Tomcat 4.1.
    My calss path is :
    C:\Program Files\Java\javamail-1.3.1\mail.jar;C:\Program Files\Java\jaf-1.0.2\activation.jar;C:\Program Files\Java\javamail-1.3.1\lib\smtp.jar;C:\Program Files\Java\j2sdk1.4.1_03\jre\lib\ext;c:\oracle9i\lib\classes12.zip;C:\Program Files\Java\jwsdp-1.1\jaxp-1.2.2\lib\jaxp-api.jar;C:\Program Files\Java\jwsdp-1.1\common\lib\jdbc2_0-stdext.jar;C:\struts\contrib\struts-el\lib\struts.jar;C:\Program Files\Java\j2sdk1.4.1_03\jre\lib;C:\Program Files\Java\j2sdk1.4.1_03\jre\lib\jsdk.jar;C:\Program Files\Java\j2sdk1.4.1_03\jre\lib;C:\Program Files\Apache JServ 1.1.2\ApacheJserv.jar;c:\struts\webapps\esosr;C:\JCO2.1.0\sapjco.jar;
    The following program works fine when run from the Dos Prompt Java TestSendMail
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.Properties;
    public class TestSendMail {
    public static void main(String args[]) {
    Properties props = System.getProperties();
    props.put("mail.smtp.host", "our.smtp.host");
    Session session = Session.getDefaultInstance(props, null);
    try {
    Message msg = new MimeMessage(session);
    msg.setFrom(new InternetAddress("myemail.com"));
    msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse("myemail.com", false));
    msg.setSubject("Hello !");
    msg.setText("Hello there");
    msg.setHeader("X-Mailer", "Test-Send");
    Transport.send(msg);
    } catch (AddressException ae) {
    ae.printStackTrace();
    } catch (MessagingException me) {
    me.printStackTrace();
    I receive the e-mail ...
    When I use it in the app same class. In the console of the Tomcat server I am getting an exeption javax.mail.NoSuchProviderException : smtp....
    Tomcat has also activation.jar; and mail.jar in it's \common\lib directory, I modified the classpath statement in catalina.bat to include the mail.jar, activation.jar and smtp.jar. and I am getting the same error. Does anyone have a suggestion why it is not working in Tomcat 4.1. Please Help !
    Thanks

    Thanks for answering!
    I do have it in the JAVA_HOME\jre\lib\ext directory as well.

  • Error javax.mail.NoSuchProviderException: pop3

    When my application runs within JBuilder everything works fine. But with a native executable I get the following error: javax.mail.NoSuchProviderException: pop3.
    The Dependencies property for JavaMail=Include Dependencies. When set to Include All the native executable not even starts.
    What is wrong here?
    Greetings,
    Hans

    I had some difficulty looking for a solution to this problem.
    All solutions 'beat about the same bush' but I couldnt get any of them to work.
    My advice is dont give up- the problem will eventually be resolved.
    How I resolved it was to assume, ( rightly) that when working inside JBuilder, it is not using the machine classpath to find library files such as mail.jar, but looking at its own library of jar files to find mail.jar.
    I tracked down the JBuilder mail.jar in the /lib dir and copied out all classes beginning with POP... also all non Class files eg proviider and map files , the mailcap file and all files beginning with SUN, and also the Manifest file and placed them in a separate folder on the hard drive.
    I then made an application jar definition from my JBuilder application but told it NOT to make a manifest file.I then right clicked on the build file, and selected properties/content and added in all files from the directory that I previously made containing the files mentioned above.
    To the Manifest file in that directory I also added the mine Main Class: to tell it where my main class was.
    I then re-built the executable jar file.
    It worked. Just when I was down to pulling out the last tuft of hair.
    Message was edited by:
    1straybullet

  • NoSuchProviderException: No provider for Address type: rfc822

    this is the stack : No provider for Address type: rfc822
    javax.mail.NoSuchProviderException: No provider for Address type: rfc822
         at javax.mail.Session.getTransport(Session.java:475)
         at javax.mail.Transport.send0(Transport.java:154)
         at javax.mail.Transport.send(Transport.java:80)
    I know what it means....but why it happens?
    please help!!!!!!!!!!!!

    [joyrex75],
    I suspect that the CLASSPATH settings on the machine that you are using is pointing only to the mail.jar file. If you are setting up the Java runtime environment that includes only the mail.jar file, your runtime environment will not have the mail providers such as the POP3, IMAP or SMTP .jar files.
    Point your CLASSPATH to the mailapi.jar file which contains the JavaMail APIs and all the mail protocol providers that SUN supports i.e. POP3, IMAP and SMTP. Try to execute the java command on your JavaMail application and see if throws out the Exception again.
    HTH.
    Allen Lai
    Developer Technical Support
    SUN Microsystems
    http://www.sun.com/developers/support/

  • Javax.mail.NoSuchProviderException: No provider for imap

    Dear All,
    Currently i am running weblogic 5.1 for my javamail Application/WebMail. I have copied mail.jar, activation.jar,pop3.jar,imap.jarmailapi.jar in weblogic\jre1_2\jre\lib\ext folder. I get "javax.mail.NoSuchProviderException: No provider " exception when i run jsp page.
    Balaji

    It looks like weblogic 5.1 (atleast the mail.jar) doesn't contain the pop3.jar, I guess. Check whether you can include pop3.jar in ur classpath..
    -Narasimha

  • JavaMailSenderImpl - NoSuchProviderException: smtp - duplicate in classpath

    I have been having an issue a:
    NoSuchProviderException: smtp
    Exception. I have read all of the forums saying its either missing 'smtp.jar' or 'activation.jar' in the classpath, but that is not the case for me. I have the full mail.jar (1.4 from maven) and activation 1.1. The problem is that when the "mail-1.4.jar" jar IS in my classpath, I encounter this exception.
    I am assuming that one of the dependent jars contains some file/class that registers the smtp protocol somewhere else, or there is another version of mail somewhere buried in the dependancies, but not 100% sure, and cant find it.
    Does anyone know why this could be happening? Or what specific files/classes I can look for that would register the smtp protocol?

    Even with mail.debug=true, I dont get more detailed messages - or anymore from javax.mail. The only error is:
    06-23-2010 14:49:25 ERROR[com.cable.wuntee.neto.nse.taac.controller.RemoteVendorAccessController] - com.cable.wuntee.neto.nse.taac.exception.TaacCreationException: Error creating Taac: Mail server connection failed; nested exception is javax.mail.NoSuchProviderException: smtp
    06-23-2010 14:49:25 ERROR[com.cable.wuntee.neto.nse.taac.controller.RemoteVendorAccessController] - Error processing request:
    com.cable.wuntee.neto.nse.taac.exception.TaacCreationException: Error creating Taac: Mail server connection failed; nested exception is javax.mail.NoSuchProviderException: smtp
            at com.cable.wuntee.neto.nse.taac.business.TaacWorkshop.createTaac(TaacWorkshop.java:262)
            at com.cable.wuntee.neto.nse.taac.controller.RemoteVendorAccessController.processRequest(RemoteVendorAccessController.java:111)
            at com.cable.wuntee.neto.nse.taac.controller.RemoteVendorAccessController$$FastClassByCGLIB$$63639bdf.invoke(<generated>)
            at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
            at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:692)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
            at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:67)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
            at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:625)
            at com.cable.wuntee.neto.nse.taac.controller.RemoteVendorAccessController$$EnhancerByCGLIB$$84cb1cb7.processRequest(<generated>)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.doInvokeMethod(HandlerMethodInvoker.java:710)
            at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:167)
            at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:414)
            at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:402)
            at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771)
            at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
            at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
            at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:563)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)It is running as through tomcat, and I can see that the runtime variables are:
    /usr/lib/jvm/jre-1.6.0-sun.x86_64//bin/java -Dcatalina.ext.dirs=/usr/share/tomcat5/shared/lib:/usr/share/tomcat5/common/lib -Dcatalina.ext.dirs=/usr/share/tomcat5/shared/lib:/usr/share/tomcat5/common/lib -Dsun.lang.ClassLoader.allowArraySyntax=true -Dmail.debug=true -Djava.endorsed.dirs=/usr/share/tomcat5/common/endorsed -classpath /usr/lib/jvm/jre-1.6.0-sun.x86_64//lib/tools.jar:/usr/share/tomcat5/bin/bootstrap.jar:/usr/share/tomcat5/bin/commons-logging-api.jar:/usr/share/java/mx4j/mx4j-impl.jar:/usr/share/java/mx4j/mx4j-jmx.jar -Dcatalina.base=/usr/share/tomcat5 -Dcatalina.home=/usr/share/tomcat5 -Djava.io.tmpdir=/usr/share/tomcat5/temp org.apache.catalina.startup.Bootstrap start

  • Why has there NoSuchProviderException in JAR file?

    My program run well in jbuilder IDE, but after i make the project into JAR file, I meet the exception:
    javax.mail.NoSuchProviderException: No provider for smtp
    i set the classpath well, because my other program(.class) sending email well.
    who knows what should i do?

    Please kindly send the solution for this problem.
    My program runs well since Web Gain-Visual Cafee in a windows 2000 machine, but when I make the project (a setup file) install it in a Windows 98 machine, it gives NoSuchProviderException No Provider for rfc822.

  • NoSuchProviderException what is it?

    Dear All...
    I'm trying to create an application (J2SE not J2EE - or Client Programs Like OpenOffice.org Writer) that sends some information to
    an email, for example [email protected], from ([email protected]) by using smtp (mydomain.com)
    but during sending the message it gives me this exception: javax.mail.NoSuchProviderException: No provider for Address type: rfc822
    here is the code...
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.mail.Transport;
    import java.util.*;
    import java.io.*;
    public class SendMail{
         public void postMail( String recipients[ ], String subject, String message, String from) throws MessagingException{
              boolean debug = false;
              Properties props = new Properties();
              props.put("mail.smtp.host", "mydomain.com");
              props.put("mail.smtp.port", "25");
              Session session = Session.getDefaultInstance(props, null);
              session.setDebug(debug);
              MimeMessage msg = new MimeMessage(session);
              InternetAddress addressFrom = new InternetAddress(from);
              msg.setFrom(addressFrom);
              InternetAddress[] addressTo = new InternetAddress[recipients.length];
              for (int i = 0; i < recipients.length; i++)     {
                   addressTo[i] = new InternetAddress(recipients);
              msg.setRecipients(Message.RecipientType.TO, addressTo);
              msg.addHeader("MyHeaderName", "myHeaderValue");
              msg.setSubject(subject);
              msg.setContent(message, "text/plain");
              System.out.println("before sending");
              Transport.send(msg);
         public static void main(String args[]) throws MessagingException{
              SendMail o = new SendMail();
              for(int i = 0; i<100; i++){
                   String to[]={"[email protected]"};
                   String from="[email protected]";
                   String msg="Message";
                   String sub="Sub";
                   System.out.println("sending... : "+i);
                   o.postMail(to,sub,msg,from);
                   System.out.println("sending over...");
    thank you for help, Amanj                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Dear JTech...
    i use the same code, and the same host (mydomain.com) in an J2EE application using JSP...
    but now i want to use the code one an client application (why during running on my computer it dont work)????
    thank you

  • Javax.mail.NoSuchProviderException

    Hi!
    I have written a java program for sending mail. I 'm getting these error msgs when i run the program. I have used Netbeans 5.5 ,so I have JavaMail jar files and Java Activation Jar file associated with my web application already. can u please help me?
    here is the error msg
    Messaging Exception Occured:-->javax.mail.NoSuchProviderException: No provider for smtp.gmail.com javax.mail.NoSuchProviderException: No provider for smtp.gmail.com at javax.mail.Session.getProvider(Session.java:455) at javax.mail.Session.getTransport(Session.java:650) at javax.mail.Session.getTransport(Session.java:631) at Mailtest.MailClient.send(MailClient.java:92) at Mailtest.MailClient.doGet(MailClient.java:51) at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:397) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:278) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536) at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:240) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:179) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:182) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566) at com.sun.enterprise.web.VirtualServerPipeline.invoke(VirtualServerPipeline.java:120) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:137) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939) at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:239) at com.sun.enterprise.web.connector.grizzly.ProcessorTask.invokeAdapter(ProcessorTask.java:667) at com.sun.enterprise.web.connector.grizzly.ProcessorTask.processNonBlocked(ProcessorTask.java:574) at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:844) at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:287) at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:212) at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252) at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:75)
    And here goes my code
    package Mailtest;
    import java.io.*;
    import java.net.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.util.Properties;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.servlet.ServletException;
    import javax.mail.Authenticator;
    import javax.mail.PasswordAuthentication;
    import javax.mail.NoSuchProviderException;
    * @author mitalib
    * @version
    public class MailClient extends HttpServlet {
    /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
    * @param request servlet request
    * @param response servlet response
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.println("<html>");
    out.println("<head>");
    out.println("<title>First Servlet</title>");
    out.println("</head>");
    out.println("<body bgcolor=\"white\">");
    out.println("<h1>Hello welcome to Mailing Service </h1>");
    out.println("<h2>Sending mail </h2>");
    try
    send("[email protected]", "[email protected]", "First Program ", "First Mail send by Servlet");
    out.println("\nMail send successfully-----");
    catch(AddressException ae)
    out.println("Address Exception Occured-->"+ae.getMessage());
    ae.printStackTrace(out);
    catch(MessagingException me)
    out.println("Messaging Exception Occured:-->"+me);
    me.printStackTrace(out);
    out.println("</body>");
    out.println("</html>");
    public void send(String s, String s1, String s3, String s4)
    throws AddressException, MessagingException
    String strHost = "smtp.gmail.com";
    Transport trans = null;
    int intPort =465;
              Address recp[];
              Address from = new InternetAddress(s);
              recp = new InternetAddress[1];
              recp[0] = new InternetAddress(s1);
              //recp[1] = new InternetAddress(s2);
    Properties prop = new Properties();
         prop.put("mail.transport.protocol","smtp");
    prop.put("mail.smtp.host", strHost);
    prop.put("mail.smtp.port", ""+intPort);
    prop.put("mail.smtps.auth ","true ");
    prop.put("mail.smtp.starttls.enpable","true");
    SMTPAuthenticator auth = new SMTPAuthenticator("[email protected]", "XXXXXXXXXX");
    Session session = Session.getDefaultInstance(prop, auth);
    session.setDebug(true);
              trans = session.getTransport(strHost);
              trans.connect(strHost,"[email protected]","xxxxxxxxxx");
              MimeMessage msg = new MimeMessage(session);
    msg.setFrom(from);
    msg.addRecipient(Message.RecipientType.TO, recp[0]);
    msg.setSubject(s3);
    msg.setText(s4);
              trans.sendMessage(msg,recp);
    class SMTPAuthenticator extends Authenticator
    public SMTPAuthenticator(String s, String s1)
    user = s;
    password = s1;
    public PasswordAuthentication getPasswordAuthentication()
    return new PasswordAuthentication(user, password);
    private String user;
    private String password;
    Please Help.
    Thanks in advance

    String strHost = "smtp.gmail.com";...
              trans = session.getTransport(strHost);You figured out that the above line is the line that caused the
    problem, right?
    And then after reading the javadocs that say:
    Get a Transport object that implements the specified protocol.
    You just couldn't figure out why "smtp.gmail.com" was not a valid
    protocol, right?
    The protocol name is "smtp". "smtp.gmail.com" is a host name.

  • Es1javax.mail.NoSuchProviderException: No provider for pop3 ?

    What is wrong with this code?Do i need to specify a Provider? Where and when?
    String host = ...;
    String username = ...;
    String password = ...;
    // Create empty properties
    Properties props = new Properties();
    // Get session
    Session ses = Session.getDefaultInstance(props, null);
    // Get the store
    Store store = ses.getStore("pop3");
    store.connect(host, username, password);
    // Get folder
    Folder folder = store.getFolder("INBOX");
    folder.open(Folder.READ_ONLY);
    // Get directory
    Message message[] = folder.getMessages();
    for (int i=0, n=message.length; i<n; i++) {
    System.out.println(i + ": " + message.getFrom()[0]
    + "\t" + message[i].getSubject());
    // Close connection
    folder.close(false);
    store.close();
    Thank you all
    Dena

    [denapuerta],
    The exception that you are getting may mean that the java runtime environment that you are running your class file code on does not seem to have the JavaMail .jar files installed correctly. The JavaMail API packages are optional packages and must be downloaded and added to the J2SE runtime environment before such an application can run successfully.
    From the exception message, looks like either the pop3.jar file or the mailapi.jar (which contains all the JavaMail API and provider library files) is missing from the CLASSPATH of the JRE or not installed onto the <JRE install directory>/jre/lib/ext directory.
    What is wrong with this code?Do i need to specify a
    Provider? Where and when?I assume you obtained the code from the jGuru tutorial on JavaMail (which is a good tutorial to start off with). I have tested the code before and it works perfectly fine.
    String host = ...;
    String username = ...;
    String password = ...;
    // Create empty properties
    Properties props = new Properties();
    // Get session
    Session ses = Session.getDefaultInstance(props, null);
    // Get the store
    Store store = ses.getStore("pop3");
    store.connect(host, username, password);
    // Get folder
    Folder folder = store.getFolder("INBOX");
    folder.open(Folder.READ_ONLY);
    // Get directory
    Message message[] = folder.getMessages();
    for (int i=0, n=message.length; i<n; i++) {
    System.out.println(i + ": " +
    + message.getFrom()[0]
    + "\t" + message[i].getSubject());
    // Close connection
    folder.close(false);
    store.close();
    Thank you all
    Dena
    You might also want to check the username/password and hostname string entries to see if you are really connecting to the POP3 mail server correctly.
    HTH.
    Allen Lai
    Developer Technical Support
    SUN Microsystems
    http://www.sun.com/developers/support/

  • How to strore keys in KeyStores..of JCE Api..

    Hi ,
    i'm trying to implement a program mySignature that creates and verifies digital signatures using Java Cryptography Extension.
    I am using the DSA Algorithm for encryption.
    Now the problem is once i create the private keys and public keys i am not able to store them to the KeyStore.
    here is the code I wrote
    package my.security.test;
    import java.io.BufferedInputStream;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.security.Certificate;
    import java.security.InvalidAlgorithmParameterException;
    import java.security.InvalidKeyException;
    import java.security.KeyPair;
    import java.security.KeyPairGenerator;
    import java.security.KeyStore;
    import java.security.KeyStoreException;
    import java.security.NoSuchAlgorithmException;
    import java.security.NoSuchProviderException;
    import java.security.PrivateKey;
    import java.security.PublicKey;
    import java.security.SecureRandom;
    import java.security.Signature;
    import java.security.SignatureException;
    import java.security.cert.CertificateException;
    import java.security.cert.CertificateFactory;
    import java.security.interfaces.RSAPrivateKey;
    import java.security.interfaces.RSAPublicKey;
    import java.security.spec.RSAKeyGenParameterSpec;
    * @author sandeepk
    * To change this generated comment edit the template variable "typecomment":
    * Window>Preferences>Java>Templates.
    * To enable and disable the creation of type comments go to
    * Window>Preferences>Java>Code Generation.
    public class MySignature {
         public static void main(String[] args) {
              KeyPairGenerator keyGen = null;
              FileOutputStream sigfos = null;
              try {
                   Signature signature = Signature.getInstance("SHA1withDSA", "SUN");
                   keyGen = KeyPairGenerator.getInstance("DSA", "SUN");
                   keyGen.initialize(1024);
                   KeyPair keyPair = keyGen.generateKeyPair();
                   PrivateKey privateKey = keyPair.getPrivate();
                   PublicKey publicKey = keyPair.getPublic();
                   KeyStore ks = KeyStore.getInstance("JKS", "SUN");
                   System.out.println("Here1");
                   ks.setKeyEntry("privkey", privateKey, "pass".toCharArray(), null);
                   System.out.println("Here2");
                   ks.setKeyEntry("pubkey", publicKey, "pass".toCharArray(), null);
                   System.out.println("Here3");
                   sigfos = new FileOutputStream("C:\\keystore");
                   ks.store(sigfos, "pass".toCharArray());
                   signature.initSign(privateKey);
                   // Reading the contents of them message file               
                   FileInputStream fis = new FileInputStream("C:\\message.txt");
                   BufferedInputStream bufin = new BufferedInputStream(fis);
                   byte[] buffer = new byte[1024];
                   int len;
                   while (bufin.available() != 0) {
                        len = bufin.read(buffer);
                        signature.update(buffer, 0, len);
                   bufin.close();
                   // Writng the signature to a file
                   byte[] realSig = signature.sign();
                   sigfos = new FileOutputStream("C:\\sig.txt");
                   sigfos.write(realSig);
                   sigfos.close();
              } catch (InvalidKeyException e) {
                   e.printStackTrace();
              } catch (NoSuchAlgorithmException e) {
                   e.printStackTrace();
              } catch (FileNotFoundException e) {
                   e.printStackTrace();
              } catch (SignatureException e) {
                   e.printStackTrace();
              } catch (IOException e) {
                   e.printStackTrace();
              } catch (NoSuchProviderException e) {
                   e.printStackTrace();
              } catch (KeyStoreException e) {
                   e.printStackTrace();
              }catch(CertificateException e){
                   e.printStackTrace();
    I get an error while i try to store the key on to the KeyStore, if I comment out these lines of code the program runs without any probs.
    Can any one help me with this issue, i'ld be thank full to them
    -Chau
    Sandy

    We use 'PDDocCreateWordFinder' , 'PDWordFinderEnumWords' to extract the text from Adobe Reader document through Code, Not tool.
    But, by using these APIs, I can't see any difference in 'new line/row' or 'paragraph' if exists in PDF doc.
    I need such API which can give the exact format of Adobe Reader doc according to the content exists in that PDF doc.
    Thanks!

Maybe you are looking for

  • Error in process Chain at 'AND' Step

    Hi, I have a Process chain which has different process which are activating different DSO's plus a loading data to a DSO in same level of Process chain. Now the next process is AND step, which will be executed if all the above process are successful.

  • Lauching iTunes 10.5.1.42

    After upgrading iTunes to ver 10.5.1.42, I get error that a required iTunes component is not installed.  Please Repair or Reinstall iTunes. (-42404) I've tried repairing iTunes and reinstalling iTunes but still get same message.  I have done this on

  • My iPhone 6 won't cant connect to the Apple Store help

    My iPhone 6 comes up with the message can not connect to the Apple Store? help what do I do to fix this?

  • BSP-Webtemplate "No Authorization"  problem.

    Hello All, In our BSP application we are calling the webtemplates. Recently i have developed a webtemplate, and called it from the BSP then in the screen area where the table object should be shown, "No Authorization" message is displayed. I can see

  • Quicktime Player Show movie info window

    How do you set it up that Quicktime Player automatically opens that window when it launches? I've have my QT player set so that it does this for so long that I forgot how I set it, but I accidentally closed the info window one day & quit QT Player. W