JavaMail Resources

I have no idea on how to make this so this is my question to you? How do i setup my JavaMail Resources in Glassfish? There are a resource file on the server already that is called mail/MyMailSession. If i understand this right i need to setup a JavaMail Resource in Glassfish but i have no idea how to make this. My friend sent me the text below but i don't really understand this so i wonder if there is somebody out there who could help/guide me thru this issue? I have GlassFish Tools Bundle For Eclipse Version: 1.2 Based on Eclipse build id: M20090917-0800 installed on my Mac.
mail resursen mail/MyMailSession
Issues Related to JavaMail
Cannot Configure JavaMail Resources Description
You cannot configure JavaMail resources using the Administration Console.
Solution
JavaMail resources are not supported by Enterprise Server v3 Prelude. The mail.jar and activation.jar files are bundled so that you can create and use mail sessions. However, you cannot obtain mail sessions from a predefined XML resource.

Get the final version of GlassFish v3, including the Eclipse plugin, which removes all these limitations.
Then you can create a JavaMail resource using the admin console or GUI, and reference it in your
application using the normal Java EE techniques.

Similar Messages

  • Tomcat and JavaMail Sessions problem

    I'm using Tomcat (with struts). I've configured my web application in server.xml to manage JavaMail Sessions:
              <Resource name="mail/Session" auth="Container" type="javax.mail.Session"/>
              <ResourceParams name="mail/Session">
                   <parameter>
                        <name>mail.smtp.host</name>
                        <value>gandalf</value>
                   </parameter>
              </ResourceParams>
    Also, I've configured my web application deployment descriptor (web.xml) to use this resource:
    <resource-ref>
         <description>JavaMail Resource</description>
         <res-ref-name>mail/Session</res-ref-name>
         <res-type>javax.mail.Session</res-type>
         <res-auth>Container</res-auth>
    </resource-ref>
    Now in the Java code I try to get the JavaMail session in this way:
    private Context devuelveContexto() throws javax.naming.NamingException
    initContext = new InitialContext();
    return (Context) initContext.lookup("java:/comp/env");
    public javax.mail.Session devuelveSesionMail()
    throws javax.naming.NamingException
    Context envContext = devuelveContexto();
    javax.mail.Session mailSesion = (javax.mail.Session) envContext.lookup("mail/Session"); <--- this throws an exception
    I'm doing all like is explained in Tomcat help web page 'JNDI Resources HOW-TO' but it doesn' work for me.
    The exception raised is this:
    java.lang.reflect.InvocationTargetException: java.lang.ClassCastException: javax.mail.Session
         at com.aplicacionesweb.evaluaciones.ddbb.CargadorRecursos.devuelveSesionMail(CargadorRecursos.java:76)
         at com.aplicacionesweb.evaluaciones.fases.actions.ConcertacionAction.enviarCorreo(ConcertacionAction.java:562)
         at com.aplicacionesweb.evaluaciones.fases.actions.ConcertacionAction.grabarConcertacion(ConcertacionAction.java:510)
         at java.lang.reflect.Method.invoke(Native Method)
         at org.apache.struts.actions.DispatchAction.perform(DispatchAction.java:236)
         at org.apache.struts.action.ActionServlet.processActionPerform(ActionServlet.java:1787)
    Please help.

    Problem solved. I had 'mail.jar' and 'activation.jar' in 'WEB-INF/lib' directory, causing a classes conflict.

  • Using Resource Reference to JavaMail Session Resource

    Hi,
    Wondering whether someone can give me some helpful pointers to solve the following issue. I have a servlet app, which at some point needs to sent emails. In order to do so, I want to use a JNDI lookup to a JavaMail session resource. Here is a code snippet:
          Context envCtx  = (Context)ehHelper.getContext().lookup("java:comp/env");
          Session session = (Session)envCtx.lookup("mail/Session");
      ...I have supplied information to my web.xml in order to let enable binding the appropriate information in OC4J. Here is a part of my web.xml:
      <resource-ref>
        <description>Resource reference to a factory for javax.mail.Session instances that may be used for sending electronic mail messages, preconfigured to connect to the appropriate
        SMTP server.</description>
        <res-ref-name>mail/Session</res-ref-name>
        <res-type>javax.mail.Session</res-type>
        <res-auth>Container</res-auth>
      </resource-ref>I use iAS9.0.3 OEM to deploy the ear to the application server and can now enter Resource Reference (and Context Attributes) in the Environment page of the web module. So I supply:
    Name: mail/Session
    Type: javax.mail.Session
    Authorization: Container
    Lookup Context: mail/Session
    Context Attributes
    Name: mail.smtp.host
    Value: skywalker.kantoor.officeIf I run the servlet I get the following error:
    Naming exception Error instantiating web-app JNDI-context: Error accessing lookup-context for resource 'mail/Session': javax.naming.NameNotFoundException: mail/Session not foundI hope someone can put me on the right track.
    Regards,
    Jan.

    Hi
    Could you please send me the details?
    I need to send mail from a jsp, we are using Oc4J 2.2.6 R2.
    Your help would be appreicated a lot.
    Thanks

  • Is there any problem to use multiple threads to send email with JavaMail

    Dear all,
    I am using JavaMail 1.3.2 to send emails with SMTP, it works very well for a long time.
    But one day, I found that the email service hanged and I could never send email again until I restart the tomcat. I found that the reason was a deadlock had been created, the required resource for sending email had not been released.
    I guess the error is due to multiple threads are sending email at the same time. I made a test to create seperate thread for sending each email. After few days, I found this deadlock happened again. So, my question is: Can I use JavaMail with multiple threads? If not, I may need to sychronized all the thread that using JavaMail. I would like to make sure this is the reason for causing the deadlock problem.
    Here is part of my code for using JavaMail:
    transport = session.getTransport("smtp");
    transport.connect(email_host, smtp_user, smtp_pass);
    message.saveChanges();
    transport.sendMessage(message,message.getAllRecipients());
    which is very standard call, and it worked well for a long time.
    Here is part for my thread dump on tomcat:
    (Thread-339)
    - waiting to lock <0x5447c180> (a sun.nio.cs.StandardCharsets)
    (Thread-342)
    - locked <0x5447c180> (a sun.nio.cs.StandardCharsets)
    It seems that these happened after call the method transport.sendMessage() or message.updateChanges()
    , and the underlying implementation may require the JRE StandardCharsets object. But the object had been locked and never be released. So, the sendMessage() or updateChanges() can't be completed.
    Please give me some helps if you have any idea about it.
    Thanks very much!
    Sirius

    Note that the Nightly build gets updated daily (and sometimes more than once in case of a respin) and it is always possible that something goes wrong and it doesn't work properly, so be prepared for issues if you decide to stay with the Nightly build and make sure to have the current release with its own profile installed as well in case of problems.
    See also:
    * http://kb.mozillazine.org/Testing_pre-release_versions
    *http://kb.mozillazine.org/Creating_a_new_Firefox_profile_on_Windows
    *http://kb.mozillazine.org/Shortcut_to_a_specific_profile
    *http://kb.mozillazine.org/Using_multiple_profiles_-_Firefox

  • Override JNDI names in persistence.xml and @resource annotation

    I have a Java EE 7 application that I am developing for use with both GlassFish and WildFly, but I have discovered that both application servers use a slightly different format for specifying JNDI names.
    In GlassFish the persistence.xml file references the data source jdbc/myDataSouce, but in WildFly the data source needs to be java:/jdbc/myDataSource.The same is also true for classes that are annotated with @Resource. In GlassFish the annotation for a class using JavaMail would be @Resource(name = "mail/myMailSession"), but to deploy onto WildFly this would need to be @Resource(name = "java:mail/myMailSession").
    The only solution I've got at present is using Maven to create two different releases of the EAR file, with one EAR file containing a persistence.xml file with the data source jdbc/myDataSouce for use with GlassFish, and the second EAR file containing a persistence.xml file with the data source java:/jdbc/myDataSource for use with WildFly. Unfortunately, I haven't found a solution for the @Resource annotation.
    I've taken a look at the documentation for glassfish-application.xml and glassfish-ejb-jar.xml and have tried using resource-ref to override the JNDI names but the application fails to deploy due to an error in the name.
    My question is does GlassFish provide any capability to override the JNDI names specified in the persistence.xml file and classes with the @resource annotation?
    Many Thanks
    Paul

    Have you been able to solve this? I'm attempting to understand what Web Server 7 can do with regard to Java Persistence and what elements of it require Glassfish.
    I've also spent great amounts of time in WS6.1 trying to figure out why a JNDI resource couldn't be found. The rules of thumb I've learned are:
    - Try dropping the *'java:/comp/env/* prefix; just use jdbc/pact part
    - Make sure all referrences (in web.xml and sun-web.xml) are identical with regard to that name.
    I'm hoping you're not still dealing with this (it's been two months!) but if anybody else stumbles on this, maybe it'll help them.
    Dave

  • Trying to send e-mail using JavaMail, JBoss 5, and JNDI

    Hello there,
    Am using JBoss 5.1.0GA and JDK 1.5.0_19 on OS X Leopard.
    Created a working SendMailServlet.
    Have now decided to refactor it into two separate classes (extract out JavaMail code to a separate class and create a ServletController).
    Am also trying to use JNDI to access the connection properties in the mail-service.xml configuration file residing in JBoss.
    The Mailer class contains the reusable functionality needed to send an e-mail:
    public class Mailer {
         private Session mailSession;
         protected void sendMsg(String email, String subject, String body)
         throws MessagingException, NamingException {
              Properties props = new Properties();
              InitialContext ictx = new InitialContext(props);
              Session mailSession = (Session) ictx.lookup("java:/Mail");
    //          Session mailSessoin = Session.getDefaultInstance(props);
              String username = (String) props.get("mail.smtps.user");
              String password = (String) props.get("mail.smtps.password");
              MimeMessage message = new MimeMessage(mailSession);
              message.setSubject(subject);
              message.setRecipients(javax.mail.Message.RecipientType.TO,
                        javax.mail.internet.InternetAddress.parse(email, false));
              message.setText(body);
              message.saveChanges();
              Transport transport = mailSession.getTransport("smtps");
              try {
                   transport.connect(username, password);
                   transport.sendMessage(message, message.getAllRecipients());
                   Logger.getLogger(this.getClass()).warn("Message sent");
              finally {
                   transport.close();
    }The MailController class serves as a standard Java Servlet which invokes the Mailer.class's sendMsg() method:
    public class MailController extends HttpServlet {
         /** static final HTML setting for content type */
         private static final String HTML = "text/html";
         myapp/** static final HTML setting for content type */
         private static final String PLAIN = "text/plain";
         public void doGet(HttpServletRequest request, HttpServletResponse response)
         throws ServletException, IOException {
              doPost(request, response);
         public void doPost(HttpServletRequest request, HttpServletResponse response)
         throws ServletException, IOException {
              response.setContentType(PLAIN);
              PrintWriter out = response.getWriter();
              String mailToken = TokenUtil.getEncryptedKey();
              String body = "Hello there, " + "\n\n"
                        + "Wanna play a game of golf?" + "\n\n"
                     + "Please confirm: https://localhost:8443/myapp/confirm?token="
                     + mailToken + "\n\n" + "-Golf USA";
              Mailer mailer = new Mailer();
              try {
                   mailer.sendMsg("[email protected]", "Golf Invitation!", body);
                   out.println("Message Sent");
              catch (MessagingException e) {
                   e.printStackTrace();
              catch (NamingException e) {
                   e.printStackTrace();
    }Have the mail configuration set under $JBOSS_HOME/server/default/deploy/mail-service.xml:
    <server>
      <mbean code="org.jboss.mail.MailService" name="jboss:service=Mail">
        <attribute name="JNDIName">java:/Mail</attribute>
        <attribute name="User">user</attribute>
        <attribute name="Password">password</attribute>
        <attribute name="Configuration">
          <configuration>
            <property name="mail.store.protocol" value="pop3"/>
            <property name="mail.transport.protocol" value="smtp"/>
            <property name="mail.user" value="user"/>
            <property name="mail.pop3.host" value="pop3.gmail.com"/>
            <property name="mail.smtp.host" value="smtp.gmail.com"/>
            <property name="mail.smtp.port" value="25"/>
            <property name="mail.from" value="[email protected]"/>
            <property name="mail.debug" value="true"/>
          </configuration>
        </attribute>
        <depends>jboss:service=Naming</depends>
      </mbean>
    </server>web.xml (Deployment Descriptor):
    <servlet>
        <servlet-name>MailController</servlet-name>
        <servlet-class>com.myapp.MailController</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>MailController</servlet-name>
        <url-pattern>/sendmail</url-pattern>
    </servlet-mapping>This is what is outputted when I start JBOSS and click point my browser to:
    https://localhost:8443/myapp/sendmail
    [MailService] Mail Service bound to java:/Mail
    [STDOUT] DEBUG: JavaMail version 1.4ea
    [STDOUT] DEBUG: java.io.FileNotFoundException:
    /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/javamail.providers
    (No such file or directory)
    [STDOUT] DEBUG: !anyLoaded
    [STDOUT] DEBUG: not loading resource: /META-INF/javamail.providers
    [STDOUT] DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
    [STDOUT] DEBUG: getProvider() returning
    javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc]
    [STDOUT] DEBUG SMTP: useEhlo true, useAuth false
    [STDOUT] DEBUG SMTP: trying to connect to host "localhost", port 465, isSSL true
    [STDERR] javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 465;
      nested exception is:
         java.net.ConnectException: Connection refused
    [STDERR]      at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1282)
    [STDERR]      at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370)
    [STDERR]      at javax.mail.Service.connect(Service.java:275)
    [STDERR]      at javax.mail.Service.connect(Service.java:156)
    [STDERR]      at javax.mail.Service.connect(Service.java:176)
    [STDERR]      at com.myapp.Mailer.sendMsg(Mailer.java:45)
    [STDERR]      at com.myapp.MailController.doPost(MailController.java:42)
    [STDERR]      at com.myapp.MailController.doGet(MailController.java:26)Why am I getting this java.net.ConnectException: Connection refused exception?
    Happy programming,
    Mike
    Edited by: mwilson72 on Aug 21, 2009 4:49 PM

    Hi Peter,
    Nice to hear from you again!
    Per your advice, this is what my mail-service.xml config file looks like now:
    <?xml version="1.0" encoding="UTF-8"?>
    <server>
      <mbean code="org.jboss.mail.MailService" name="jboss:service=Mail">
      <attribute name="JNDIName">java:/Mail</attribute>
      <attribute name="User">user</attribute>
      <attribute name="Password">password</attribute>
      <attribute name="Configuration">
         <configuration>
            <property name="mail.store.protocol" value="pop3"/>
         <property name="mail.transport.protocol" value="smtps"/>
            <property name="mail.smtp.starttls.enable" value="true"/>
            <property name="mail.smtps.auth" value="true"/> 
            <property name="mail.user" value="user"/>
            <property name="mail.pop3.host" value="pop3.gmail.com"/>
            <property name="mail.smtp.host" value="smtp.gmail.com"/>
            <property name="mail.smtps.port" value="465"/>
            <property name="mail.from" value="[email protected]"/>
            <property name="mail.debug" value="true"/>
         </configuration>
       </attribute>
       <depends>jboss:service=Naming</depends>
      </mbean>
    </server>Now, when I restart JBoss and point my browser to:
    https://localhost:8443/myapp/sendmail
    I get this exception:
    [STDOUT] DEBUG SMTP: useEhlo true, useAuth true
    [STDOUT] DEBUG SMTP: useEhlo true, useAuth true
    [STDOUT] DEBUG SMTP: trying to connect to host "localhost", port 465, isSSL true
    [STDERR] javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 465;
      nested exception is:
         java.net.ConnectException: Connection refused
    [STDERR] at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1282)
    [STDERR] at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370)
    [STDERR] at javax.mail.Service.connect(Service.java:297)
    [STDERR] at javax.mail.Service.connect(Service.java:156)
    [STDERR] at javax.mail.Service.connect(Service.java:176)
    [STDERR] at com.myapp.Mailer.sendMsg(Mailer.java:45)
    [STDERR] at com.myapp.MailController.doPost(MailController.java:42)
    [STDERR] at com.myapp.MailController.doGet(MailController.java:26)Does anyone know what I am possibly doing wrong? Is it my code or is it the config file?
    -Mike

  • Error. Javamail. No object bound to name... Sun Java App. Server 9.0 updt 1

    Hello,
    I get this exception: No object bound to name java:comp/env/mail/SendSession
    I am trying to build automatic mail sending in my application
    I have configured my server with the next information and this code:
    -Error, exception:
    No object bound to name java:comp/env/mail/SendSession
    -Code:
    InitialContext ic = null;
    Session session = null;
    String snName = "";
    // I HAVE TRIED WITH SEVERAL STRINGS
    snName = "java:comp/env/mail/SendSession";
    //snName = "/mail/SendSession";
    //snName = "mail/SendSession";
    //snName = "/SendSession";
    //snName = "SendSession";
    try {
    ic = new InitialContext();
    session = (Session) ic.lookup(snName);
    } catch (NamingException ex) {
    Logger.getLogger("org.xxxx").warning("Error:. " + ex.getLocalizedMessage());
    -Server:
    Sun Java System Application Server Platform Edition 9.0 update 1.
    -Configuration in Sun\AppServer\domains\domain1\config\domain.xml:
    <resources>
    <mail-resource debug="true" enabled="true" from="[email protected]" host="yahoo.es" jndi-name="mail/SendSession" object-type="user" store-protocol="imap" store-protocol-class="com.sun.mail.imap.IMAPStore" transport-protocol="smtp" transport-protocol-class="com.sun.mail.smtp.SMTPTransport" user="xxxxx">
    <description>sesion envio correo</description>
    <property name="mail.transport.protocol" value="smtp"/>
    <property name="mail.smtp.server" value="smtp.mail.yahoo.com"/>
    <property name="mail.smtp.port" value="2473"/>
    </mail-resource>
    </resources>
    <servers>
    <server config-ref="server-config" lb-weight="100" name="server">
    <resource-ref enabled="true" ref="mail/SendSession"/>
    </server>
    </servers>
    I need your help.
    Thanks in advance.
    Pedro.

    (This isn't really a JavaMail question...)
    The JNDI name you use in your application
    is a name that's local to your application.
    The JNDI name that you configure in domain.xml
    is a global JNDI name.
    The two names can be different.
    In the (e.g.) sun-web.xml file you need to
    specify the mapping from the local JNDI
    name you use in your application to the
    global JNDI name you've configured in
    the server.
    If you use dependency injection to inject
    the Session object, you can specify this
    mapping in the @Resource annotation in
    your source code.

  • Using JavaMail with ESMTP exchange server

    Hi all,
    I have been looking at the FAQ, the SSLNotes.txt as well as the posted codes here and on google, but I am still having problem with the following scenario:
    An exchange ESMTP server which gave me a "Unrecognized SSL message" exception when I enabled TLS and passing in an authenticator for login.
    After experimenting with my IT manager, we concluded that the login has to be done in plain text after which TLS can then be switched to.
    So can anyone be able to provide me with a sample code for accessing such a server or point me in a direction as to how to implement a solution for it?
    Thank you very much in advance.
    Best Regards,
    James

    Sorry for the extremely late reply to your post Shannon and thank you for your help so far. I was caught up with other tasks.
    The following is the debug trace I managed to capture:
    DEBUG: JavaMail version 1.4.1
    DEBUG: not loading file: D:\Java\jdk1.5.0_11\jre\lib\javamail.providers
    DEBUG: java.io.FileNotFoundException: D:\Java\jdk1.5.0_11\jre\lib\javamail.providers (The system cannot find the file specified)
    DEBUG: !anyLoaded
    DEBUG: not loading resource: /META-INF/javamail.providers
    DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
    DEBUG: Tables of loaded providers
    DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]}
    DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]}
    DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
    DEBUG: !anyLoaded
    DEBUG: not loading resource: /META-INF/javamail.address.map
    DEBUG: not loading file: D:\Java\jdk1.5.0_11\jre\lib\javamail.address.map
    DEBUG: java.io.FileNotFoundException: D:\Java\jdk1.5.0_11\jre\lib\javamail.address.map (The system cannot find the file specified)
    DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
    DEBUG SMTP: useEhlo true, useAuth true
    DEBUG SMTP: useEhlo true, useAuth true
    DEBUG SMTP: trying to connect to host "mailbak.******.com", port 25, isSSL false
    DEBUG SMTP: exception reading response: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
    Got Exception: javax.mail.MessagingException: Exception reading response;
      nested exception is:
         javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?As before stated, I have created a DummyTrustManager and DummySocketFactory given in the SSLNotes.txt and enabled TLS and authentication via an authenticator.
    Best Regards,
    James
    Edited by: nghianja on Apr 22, 2008 3:10 PM

  • Filenotfound exception  javamail.providers

    hi, i am using java mail API to Send mails , my code is executed correctly but, all mails are goes to badmail folder of the host
    and my code is ....
    package com;
    import java.util.Properties;
    import javax.mail.Authenticator;
    import javax.mail.Message;
    import javax.mail.MessagingException;
    import javax.mail.PasswordAuthentication;
    import javax.mail.Session;
    import javax.mail.Transport;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeMessage;
    * @author gaucho
    * TODO To change the template for this generated type comment go to Window -
    * Preferences - Java - Code Style - Code Templates
    public class SendMailUsingAuthentication {
         private static final String SMTP_HOST_NAME = "192.168.2.33";
         private static final String SMTP_AUTH_USER = "[email protected]";
         private static final String SMTP_AUTH_PWD = "Password1";
         private static final String emailMsgTxt = "Please visit my project at ";
         private static final String emailSubjectTxt = "Order Confirmation Subject";
         private static final String emailFromAddress = "[email protected]";
         // Add List of Email address to who email needs to be sent to
         private static final String[] emailList = { "[email protected]"};
         public static void main(String args[]) throws Exception {
              SendMailUsingAuthentication smtpMailSender = new SendMailUsingAuthentication();
              smtpMailSender.postMail(emailList, emailSubjectTxt, emailMsgTxt,
                        emailFromAddress);
              System.out.println("Sucessfully Sent mail to All Users");
         public void postMail(String recipients[], String subject, String message,
                   String from) throws MessagingException {
              boolean debug = false;
              java.security.Security
                        .addProvider(new com.sun.net.ssl.internal.ssl.Provider());
              //Set the host smtp address
              Properties props = new Properties();
              props.put("mail.transport.protocol", "smtp");
              props.put("mail.smtp.starttls.enable","true");
              props.put("mail.smtp.host", SMTP_HOST_NAME);
              props.put("mail.smtp.auth", "true");
              props.put("mail.debug","true");
              Authenticator auth = new SMTPAuthenticator();
              Session session = Session.getDefaultInstance(props, auth);
              session.setDebug(debug);
              // create a message
              Message msg = new MimeMessage(session);
              // set the from and to address
              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);
              // Setting the Subject and Content Type
              msg.setSubject(subject);
              msg.setContent(message, "text/plain");
              Transport.send(msg);
         * SimpleAuthenticator is used to do simple authentication when the SMTP
         * server requires it.
         private class SMTPAuthenticator extends javax.mail.Authenticator {
              public PasswordAuthentication getPasswordAuthentication() {
                   String username = SMTP_AUTH_USER;
                   String password = SMTP_AUTH_PWD;
                   return new PasswordAuthentication(username, password);

    DEBUG: JavaMail version 1.3.3
    DEBUG: java.io.FileNotFoundException: C:\Program Files\Java\jre1.5.0_04\lib\javamail.providers (The system cannot find the file specified)
    DEBUG: URL jar:file:/C:/EmailAgent60/lib/imap.jar!/META-INF/javamail.providers
    DEBUG: successfully loaded resource: jar:file:/C:/EmailAgent60/lib/imap.jar!/META-INF/javamail.providers
    DEBUG: URL jar:file:/C:/EmailAgent60/lib/pop3.jar!/META-INF/javamail.providers
    DEBUG: successfully loaded resource: jar:file:/C:/EmailAgent60/lib/pop3.jar!/META-INF/javamail.providers
    DEBUG: URL jar:file:/C:/EmailAgent60/lib/smtp.jar!/META-INF/javamail.providers
    DEBUG: successfully loaded resource: jar:file:/C:/EmailAgent60/lib/smtp.jar!/META-INF/javamail.providers
    DEBUG: not loading resource: /META-INF/javamail.default.providers
    DEBUG: Tables of loaded providers
    DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsy stems, Inc]}
    DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsy stems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc]}
    DEBUG: not loading resource: /META-INF/javamail.default.address.map
    DEBUG: URL jar:file:/C:/EmailAgent60/lib/smtp.jar!/META-INF/javamail.address.map
    DEBUG: successfully loaded resource: jar:file:/C:/EmailAgent60/lib/smtp.jar!/META-INF/javamail.address.map
    DEBUG: java.io.FileNotFoundException: C:\Program Files\Java\jre1.5.0_04\lib\javamail.address.map (The system cannot find the file specified)
    DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
    DEBUG SMTP: useEhlo true, useAuth false
    DEBUG SMTP: trying to connect to host "192.168.2.33", port 25, isSSL false
    220 Dunagiri Microsoft ESMTP MAIL Service, Version: 5.0.2195.6713 ready at Wed, 12 Jul 2006 11:40:07 +0530
    DEBUG SMTP: connected to host "192.168.2.33", port: 25
    EHLO manas
    250-Dunagiri Hello [192.168.2.64]
    250-TURN
    250-ATRN
    250-SIZE 2097152
    250-ETRN
    250-PIPELINING
    250-DSN
    250-ENHANCEDSTATUSCODES
    250-8bitmime
    250-BINARYMIME
    250-CHUNKING
    250-VRFY
    250 OK
    DEBUG SMTP: Found extension "TURN", arg ""
    DEBUG SMTP: Found extension "ATRN", arg ""
    DEBUG SMTP: Found extension "SIZE", arg "2097152"
    DEBUG SMTP: Found extension "ETRN", arg ""
    DEBUG SMTP: Found extension "PIPELINING", arg ""
    DEBUG SMTP: Found extension "DSN", arg ""
    DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
    DEBUG SMTP: Found extension "8bitmime", arg ""
    DEBUG SMTP: Found extension "BINARYMIME", arg ""
    DEBUG SMTP: Found extension "CHUNKING", arg ""
    DEBUG SMTP: Found extension "VRFY", arg ""
    DEBUG SMTP: Found extension "OK", arg ""
    DEBUG SMTP: use8bit false
    MAIL FROM:<[email protected]>
    250 2.1.0 [email protected] OK
    RCPT TO:<[email protected]>
    250 2.1.5 [email protected]
    DEBUG SMTP: Verified Addresses
    DEBUG SMTP: [email protected]
    DATA
    354 Start mail input; end with <CRLF>.<CRLF>
    Message-ID: <29509536.01152684496937.JavaMail.chiranjeevi@manas>
    Date: Wed, 12 Jul 2006 11:38:16 +0530 (GMT+05:30)
    From: [email protected]
    To: [email protected]
    Subject: Test E-Mail through Java
    Cc: [email protected]
    MIME-Version: 1.0
    Content-Type: text/plain; charset=us-ascii
    Content-Transfer-Encoding: 7bit
    This is a test of sending a plain text e-mail through Java.
    Here is line 2.
    250 2.6.0 <29509536.01152684496937.JavaMail.chiranjeevi@manas> Queued mail for delivery
    DEBUG SMTP: use8bit false
    MAIL FROM:<[email protected]>
    250 2.1.0 [email protected] OK
    RCPT TO:<[email protected]>
    250 2.1.5 [email protected]
    DEBUG SMTP: Verified Addresses
    DEBUG SMTP: [email protected]
    DATA
    354 Start mail input; end with <CRLF>.<CRLF>
    Message-ID: <15277917.11152684497046.JavaMail.chiranjeevi@manas>
    Date: Wed, 12 Jul 2006 11:38:16 +0530 (GMT+05:30)
    From: [email protected]
    To: [email protected]
    Subject: Test E-Mail through Java
    Cc: [email protected]
    MIME-Version: 1.0
    Content-Type: multipart/mixed;
         boundary="----=_Part_0_19690856.1152684497031"
    ------=_Part_0_19690856.1152684497031
    Content-Type: text/plain; charset=us-ascii
    Content-Transfer-Encoding: 7bit
    This is part one of a test multipart e-mail.
    ------=_Part_0_19690856.1152684497031
    Content-Type: text/plain; charset=us-ascii
    Content-Transfer-Encoding: 7bit
    This is the second part
    ------=_Part_0_19690856.1152684497031--
    250 2.6.0 <15277917.11152684497046.JavaMail.chiranjeevi@manas> Queued mail for delivery
    DEBUG SMTP: use8bit false
    MAIL FROM:<[email protected]>
    250 2.1.0 [email protected] OK
    RCPT TO:<[email protected]>
    250 2.1.5 [email protected]
    DEBUG SMTP: Verified Addresses
    DEBUG SMTP: [email protected]
    DATA
    354 Start mail input; end with <CRLF>.<CRLF>
    Message-ID: <11587215.21152684497093.JavaMail.chiranjeevi@manas>
    Date: Wed, 12 Jul 2006 11:38:16 +0530 (GMT+05:30)
    From: [email protected]
    To: [email protected]
    Subject: Test E-Mail through Java
    Cc: [email protected]
    MIME-Version: 1.0
    Content-Type: multipart/mixed;
         boundary="----=_Part_0_19690856.1152684497031"
    ------=_Part_0_19690856.1152684497031
    Content-Type: text/plain; charset=us-ascii
    Content-Transfer-Encoding: 7bit
    This is part one of a test multipart e-mail.
    ------=_Part_0_19690856.1152684497031
    Content-Type: text/plain; charset=us-ascii
    Content-Transfer-Encoding: 7bit
    This is the second part
    ------=_Part_0_19690856.1152684497031--
    250 2.6.0 <11587215.21152684497093.JavaMail.chiranjeevi@manas> Queued mail for delivery
    DEBUG SMTP: use8bit false
    MAIL FROM:<[email protected]>
    250 2.1.0 [email protected] OK
    RCPT TO:<[email protected]>
    250 2.1.5 [email protected]
    DEBUG SMTP: Verified Addresses
    DEBUG SMTP: [email protected]
    DATA
    354 Start mail input; end with <CRLF>.<CRLF>
    Message-ID: <10807107.31152684497156.JavaMail.chiranjeevi@manas>
    Date: Wed, 12 Jul 2006 11:38:16 +0530 (GMT+05:30)
    From: [email protected]
    To: [email protected]
    Subject: Test E-Mail through Java
    Cc: [email protected]
    MIME-Version: 1.0
    Content-Type: text/html; charset=us-ascii
    Content-Transfer-Encoding: 7bit
    <html><head><title>Test E-Mail through Java</title></head><body><h1>Test E-Mail through Java</h1><p>This is a test of sending an HTML e-mail through Java.</body></html>
    250 2.6.0 <10807107.31152684497156.JavaMail.chiranjeevi@manas> Queued mail for delivery
    QUIT

  • Use of resource-env-ref tag

    Hi,
    Can anybody tell me what is the use of the resource-env-ref tag. I am using resourec-ref tag where I have specified a jdbc datasource configuration. But I do not know what does resource-env-ref do? Does it add any extra feature to the resource-ref tag? I know the use of env-entry tag. Is it similar to env-entry tag?
    Please give an example.
    Thanking in advance.

    * <env-entry> - Environment entry, a single-value
    parameter that can be used to configure how the
    application will operate.
    * <resource-ref> - Resource reference, which is
    typically to an object factory for resources such as
    a JDBC DataSource, a JavaMail Session, or custom
    object factories
    * <resource-env-ref> - Resource environment
    reference, a new variation of resource-ref added in
    Servlet 2.3 that is simpler to configure for
    resources that do not require authentication
    information.Ok, u mean to say that i can use either resource-ref or resource-env-ref tag depending on whether i require authentication or not, right?
    Also, please tell me what does the web container do with these configurations? Does it load these resources at container start-up or it simply
    creates the environment where resources can be accessed through a name like, say java:comp/env/jdbc/MyDataSource where this is again mapped to a jndi name?
    I know that using this type of configuration helps make changes to the jndi name without recompiling our servlets.
    Also, could u please tell me can we use ejbs the same way as above (using resourec-ref or resource-env-ref tag) or I must use the ejb-ref tag. Since ejbs are also bound to jndi names, they should be accessible throught the above tags and not only through the ejb-ref tag.

  • Session EJB & JavaMail

    Hi all,
    I have a stateless session EJB that looks up for a mail session object. As shown in the example, lookup(MAIL_SESSION_JNDI) should return a Session object, but I get a com.sun.enterprise.deployment.MailConfiguration instead.
    Does anyone know what is happening, and what should I do to get it working?
    Thanks,
    Dan

    Hi,
    I was wondering if someone could direct me as to using JavaMail within Weblogic. Does it provide a SMTP service of some sort? How do I provide a SMTP server. And where do I get more info on:
    weblogic.resource.MailSession.mail.Session
    I couldn't find it in the docs.
    Thanks.
    Nils Winkler <[email protected]> wrote:
    I remember having the same problem. Try creating the MailSession in
    one line (without the "\"s). I think that solved it for me IIRC. Like
    this:
    weblogic.resource.MailSession.mail.Session=mail.from=[email protected],mail.host=netmail.home.com
    Hope that helps,
    Nils
    On Tue, 8 Aug 2000 08:21:50 -0600, "Greg Hamel" <[email protected]>
    wrote:
    I'm using a Session EJB to send mail using JavaMail, however the mail
    session doesn't seem to find it's properties...
    I've setup the Mail session properties as follows, from weblogic.properties.
    # MAIL SUBSYSTEM PROPERTIES
    weblogic.resource.MailSession.mail.Session=\
    mail.from=[email protected], \
    mail.host=netmail.home.com
    My Session EJB looks up the MailSession successfully via JNDI, but when it
    attempts to actually send,
    the mailhost somehow always resolves to 'localhost', instead of the value
    specified.
    Note that this occurs within the context of a web archive.
    Any suggestions?
    Greg Hamel
    Nils Winkler
    iXL, Inc.
    [email protected]

  • JavaMail application aborts JVM on iPlanet

    I am running a JavaMail application
    on iPlanet Web Server 4.1 SP9 on Solaris 2.8.
    The iPlanet Webserver uses JDK 1.2.2_05.
    (The JDK required patches are installed.)
    The application uses JavaMail 1.3.1 and
    JAF 1.0.2 from Sun. The IMAP4 server is
    accessed using the service provider in the
    JavaMail package.
    The application calls repeatedly
    BodyPart.getContent()
    until the returned object is of type InputStream.
    When this input stream is read, the JVM aborts.
    I turned the JavaMail debug on using Session.setDebug().
    This shows, that part of the body of the mail is
    fetched before the JVM aborts.
    The application log including JavaMail:
    2003-09-17 22:39:21,860 [Thread-9] DEBUG imap4.MsgBody - int readLen = -1;
    2003-09-17 22:39:21,860 [Thread-9] DEBUG imap4.MsgBody - while ((readLen = body.
    read()) != -1) {
    2003-09-17 22:39:21,863 [Thread-9] DEBUG JAVAMAIL - A29 FETCH 11 (BODY[1]<0.16384>)
    2003-09-17 22:39:21,891 [Thread-9] DEBUG JAVAMAIL - * 11 FETCH (BODY[1]<0> {16384}
    //8NAAAAAAAAAAAAAAAAAJ48kiT05/7/Hv+eP26nbP3+/54kkusSP/7/7v+e//z78iecP/Ln
    nud85+7HkjySPP7/3jz+/57nHufy5/T/4uf++J7/Gt+S654olOee5/7k/tue+/77bvf+JP78
    ov/y/x5FkvyiP/4/Ht+cJ/Lf8iT+5PL/kieSJGIn/v7+2J4nlD+S5J7nnt/+/2zfnP9+/aQk
    8vyu//7f/v/sJO4k8iT+/JL/Hv/+5+7kEiWe/P4//Nz+//78ouT+KJ4k8v/85+zabvvy//4k
    ouSS5PLn8vv8+/rfrv/+55JH4j9+P/7f8t/+/H7/kvzyPPInfuf0//7/kj/++/77/v+ePPI/
    /vyeJ/7/kt/8P/7//v+ePPInnj/+//4/7vvyx/7/nvyeJPIk/v+e5P7n/ufu//zb/v/+//Ik
    kify/J7k9Pz+/27/8v/+//7/7uT+PP4k8if+3/7/nj+SPPInnv/+//z/fv/+5/4k/v/+//L/
    /vz8//4nkv/yJP7//v/+//7//v/+//7//v/+P/I/9D/yJ/L//t+e+/4/kiTy/+7//uf+/54/
    kiRyJZ7//v/8//7/kvz+J/4nnvz+//7/7v/8/P48kkSeJJI//v/s//zf/vz+P/LnkjwSJ/7/
    nv/+//7/fv/+/x4l8iSeJ/L/fv9s12778j/yS5Ikniee337b/tf85/78niTyJ/Lk/v9s5+zn
    /v+S/JI//ice//7//v/+257//v+SJ5L87ueS55L//sd++/7n/vz+J5I/nv/iJ/7//vwe//78
    /v+eP3L/8j+e/J7kkv/y//7//v/+//7kkuSe//7//v9uO/7/niSSJ/In8j/++/7/7vv++54/
    niSS5/L//vv+/57n/v/+JP4n8v/+//7//v/+//7//v/+//7//j/+/JLkkv/yP/7//v/+//4k
    nuSS3/7f/Nz+/5Ln8v/+//7f/v/+/5L/njyS557nfv/y/P4k8ify//7n/v/+//7/nvySJP4k
    nvx+/+7//tz+PxJf8ufy//7//v/+/5IkkiTyJP7//v/+3/7f/v/+/377kv+UJJIkkuf+/37b
    7Pt82+4nEiWSJJI/8sfs1lz7/NuSPJIo8kty5fzf6rta33z7nvyURJJHcj18/+767Lvc29JY
    KifyKyT7ktvy9xrf7j/8/27nLPtSJS47/uvyVxzf9Pucv+zfbP/qOPr/9ESuJ3T9euf++2zH
    euf++xLbfMvkWJ7kniQc23Lb8jtq/+Lf/Cfex+7nrlySJPLk7Lz+9/zfEt/+/P4/3vveOJzk
    ZCV+5/7nfvv8/+7/+v98xuI7/PiSWBI9/jx+9ew7Glv++3w6eM3s+O78nFz0WBz7/rCeP+5f
    OvN2+/6kbDMe/bI/kt8ul/
    The iPlanet error log shows, that at this moment the JVM is restarted:
    [17/Sep/2003:22:39:21] info ( 2583): Internal Info: loading servlet /Creator/callflow/htmlsara/dbg_play_msg_body.jsp
    [17/Sep/2003:22:39:21] info ( 2583): Aborting JVM
    [17/Sep/2003:22:39:21] info ( 2583): Exiting JVM due to: jvm_abort () and jvm.ex
    itOnAbort > 0
    [17/Sep/2003:22:39:21] info ( 2583): JVM exit statistics: AttachedThreads/Max=1/
    1, ActiveThreads/Max=1/1
    [17/Sep/2003:22:39:22] warning ( 2585): Unable to initialize NLS property bundle
    (res/cjava)
    [17/Sep/2003:22:39:22] catastrophe ( 2585): Unable to create/cleanup persistent
    session data cache
    [17/Sep/2003:22:39:23] warning ( 2585): sjava resource bundle not found - using
    default: java.util.MissingResourceException: Can't find resource for base name r
    es.sjava, locale en
    [17/Sep/2003:22:39:23] info ( 2585): Loading Simple Session Manager by default.
    Specify MMapSessionManager in servlets.properties to load persistent session man
    ager
    [17/Sep/2003:22:39:23] info ( 2585): SimpleSessionManager: Default values for ma
    ximum number of sessions is 1000 with a time out value of 1800 seconds
    The only public interface of the application is a bean. When this bean is
    used via a main method, then everything works. The same JVM is used
    to run the application from the command line.
    Can you give me some suggestion, how the problem can be resolved.
    Thanks

    In the mean time I found a solution to the problem.
    After reading the JavaMail forum, FAQ, Notes, and
    other resources it became obvious, that
    large attachments exhaust JVM memory.
    I minimized the memory usage of the JavaMail
    and the application, that uses the JavaMail as
    follows.
    I decreased the fetchsize of the IMAP4 client
    by setting the mail.imap.fetchsize properties to
    64 bytes.
    I do not buffer the InputStream returned by the
    Part.getContent() method.
    I decreased the buffer size used in the statement
    istream.read(buf) to 128.
    The istream is the InputStream returned by the
    Part.getContent.
    All this changes led to a JavaMail debug log, that
    showed, that JavaMail used the memory efficiently.
    JavaMail only read as many bytes as it was
    necessary to fiil the buf buffer, then I could save
    the bytes, and read the next chunk of the body.
    The price of the solution is, that the decreased memory usage resulted in a much slower system.

  • JavaMail sending error

    I was using the following code on my previous server and that was working very well
    import java.io.*;
    import java.util.*;
    import javax.mail.*;
    import javax.mail.internet.*;  
    import javax.mail.event.*;     
    import java.net.*;
    import javax.activation.*;
    public class sendEmail {
            public static void send(String from, String to,
                                    String subject, String content)
                    throws AddressException, MessagingException {
         Properties props=new Properties();
            props.put("smtp.domainName.com","hostname");
         Session   session1  =  Session.getDefaultInstance(props,null);
         Message msg =new MimeMessage(session1);
         msg.setFrom(new InternetAddress(from));
               msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to,false));
               msg.setSubject(subject);
               msg.setContent(content,"text/html");     
               Transport.send(msg); 
    }Now I changed the "smtp.domainName.com","hostname" to "IP","IP" the new server it displays following error:
    javax.mail.SendFailedException: Invalid Addresses;
    nested exception is:
    *     com.sun.mail.smtp.SMTPAddressFailedException: 553 sorry, that domain isn't in my list of allowed rcpthosts (#5.5.3 - chkuser)*
    I edited my /var/qmail/control/rcpthosts and inserted my whole domain names but still I am receiving the same error. My network company replied me that previous server was using the open relay but now we have to change the code to send the emails
    How can I resolve the issue?
    Thanks and best regards

    Hello,
    Sorry for the delayed reply
    I read carefully the JavaMail FAQs and written the following code:
    import java.util.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    import javax.swing.*;
    import com.sun.mail.smtp.SMTPMessage;
    public class sendEmail {          
            public static void send(String from, String to,
                                    String subject, String content)
                    throws AddressException, MessagingException {
             String host = "mail.domain.com";
             Properties props = new Properties();
              props.put("mail.smtp.host", host);
              props.put("mail.debug", "true");
              Session session = Session.getInstance(props);
            try {
              SMTPMessage msg = new SMTPMessage(session);
              msg.setFrom(new InternetAddress(from));
              msg.setRecipients(Message.RecipientType.TO, to);
              msg.setSubject(subject);
              Transport tr = session.getTransport("smtp");
    String username="[email protected]";
    String password="*****";
              tr.connect(host, username, password);
              tr.sendMessage(msg, msg.getAllRecipients());          
         catch (Exception mex) {
         System.out.println(mex);
    }when I ran my servlet then it throws the following exception:
    DEBUG: java.io.FileNotFoundException: /usr/java/jdk1.6.0_11/jre/lib/javamail.providers (No such file or directory)
    DEBUG: URL jar:file:/usr/lib/apache-tomcat-6.0.18/webapps/foundation/WEB-INF/lib/imap.jar!/META-INF/javamail.providers
    DEBUG: successfully loaded resource: jar:file:/usr/lib/apache-tomcat-6.0.18/webapps/foundation/WEB-INF/lib/imap.jar!/META-INF/javamail.providers
    DEBUG: URL jar:file:/usr/lib/apache-tomcat-6.0.18/webapps/foundation/WEB-INF/lib/pop3.jar!/META-INF/javamail.providers
    DEBUG: successfully loaded resource: jar:file:/usr/lib/apache-tomcat-6.0.18/webapps/foundation/WEB-INF/lib/pop3.jar!/META-INF/javamail.providers
    DEBUG: URL jar:file:/usr/lib/apache-tomcat-6.0.18/webapps/foundation/WEB-INF/lib/smtp.jar!/META-INF/javamail.providers
    DEBUG: successfully loaded resource: jar:file:/usr/lib/apache-tomcat-6.0.18/webapps/foundation/WEB-INF/lib/smtp.jar!/META-INF/javamail.providers
    DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
    DEBUG: Tables of loaded providers
    DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]}
    DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsy stems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc]}
    DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
    DEBUG: URL jar:file:/usr/lib/apache-tomcat-6.0.18/webapps/foundation/WEB-INF/lib/smtp.jar!/META-INF/javamail.address.map
    DEBUG: successfully loaded resource: jar:file:/usr/lib/apache-tomcat-6.0.18/webapps/foundation/WEB-INF/lib/smtp.jar!/META-INF/javamail.address.map
    DEBUG: java.io.FileNotFoundException: /usr/java/jdk1.6.0_11/jre/lib/javamail.address.map (No such file or directory)
    java.lang.NullPointerException1) My whole jar file i.e. activation.jar, mail.jar, smtp.jar, imap.jar are in one place /usr/lib/apache-tomcat/webapps/foundation/WEB-INF/lib as well as I copied them to /usr/java/jdk1.6.0_11/jre/lib/ even then throwing same error
    2) It sends message within the server successfully but not out of the server
    DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
    DEBUG SMTP: useEhlo true, useAuth false
    DEBUG SMTP: trying to connect to host "mail.domain.com", port 25, isSSL false
    220 system1 - Welcome to Qmail ESMTP
    DEBUG SMTP: connected to host "mail.domain.com", port: 25
    EHLO 102
    250-system1 - Welcome to Qmail
    250-STARTTLS
    250-PIPELINING
    250-8BITMIME
    250-SIZE 20971520
    250 AUTH LOGIN PLAIN CRAM-MD5
    DEBUG SMTP: Found extension "STARTTLS", arg ""
    DEBUG SMTP: Found extension "PIPELINING", arg ""
    DEBUG SMTP: Found extension "8BITMIME", arg ""
    DEBUG SMTP: Found extension "SIZE", arg "20971520"
    DEBUG SMTP: Found extension "AUTH", arg "LOGIN PLAIN CRAM-MD5"
    DEBUG SMTP: use8bit false
    MAIL FROM:<[email protected]>
    250 ok
    RCPT TO:<[email protected]>
    250 ok
    DEBUG SMTP: Verified Addresses
    DEBUG SMTP:   [email protected]
    DATA
    354 go ahead
    From: [email protected]
    To: [email protected]
    Message-ID: <12213370.01239119437962.JavaMail.root@102>
    Subject: Email Testing
    MIME-Version: 1.0
    Content-Type: text/html; charset=us-ascii
    Content-Transfer-Encoding: 7bit
    Exalted Sir/Madam,<br><br>This is email testing
    250 ok 1239119438 qp 289303) out of the server it throws following error:
    MAIL FROM:<[email protected]>
    250 ok
    RCPT TO:<[email protected]>
    553 sorry, that domain isn't in my list of allowed rcpthosts (#5.5.3 - chkuser)
    DEBUG SMTP: Invalid Addresses
    DEBUG SMTP:   [email protected]
    DEBUG SMTP: Sending failed because of invalid destination addresses
    RSET
    250 flushed
    javax.mail.SendFailedException: Invalid Addresses;
      nested exception is:
         com.sun.mail.smtp.SMTPAddressFailedException: 553 sorry, that domain isn't in my list of allowed rcpthosts (#5.5.3 - chkuser)Thanks & best regards

  • Order, Paginate and List  emails in JavaMail API

    Am able to sendm and retrieve emails in java using JavaMail API but am having a problem. I would like to sort emails by date, subject, sender etc and also display only a subset of emails using pagination.
                Message[] msgs = folder.getMessages();
                FetchProfile fp = new FetchProfile();
                fp.add(FetchProfile.Item.ENVELOPE);
                folder.fetch(msgs, fp);The function folder.getMessages(); can take 2 arguments (from_index,to_index), but this is according to the way mail server will transalate. POP server will arrange by date while IMAP is unordered. I would like to order the mails then fetch the getMessages(from_index,to_index).
    Another posible way am seeing is fetching all mesages using getMessages() put them in a temporary storage(eg. vector or list), order them and then fetch only the page i want. But this could be very costly in terms of processing resources, which makes me believe there is a better approach and it seems i cant find it.
    Can somenone please advice me on what to do. I will be very greatful.
    Edited by: kagara on Aug 27, 2008 12:27 PM

    With POP3 you have no choice but to download the messages and sort them in the client.
    The POP3 protocol simply doesn't provide a "sort" option.
    With IMAP, some IMAP servers support a "SORT" extension, although JavaMail doesn't
    support it yet.

  • JavaMail interesting error

    Hi JavaGurus,
    I am getting an error when I try to send a mail
    using an html document. I'm using JavaMail to do that. Basically when the submit button is pressed, it invokes a servlet and that servlet should an e-mail to the address in the html document that the user writes. I have narrowed down the error to this statement:
    Session session = (Session) envCtx.lookup("mail/Session");
    It gives me the following error, which is print stack trace. Any help would be appreciated. Thanks.
    Nik
    javax.naming.NameNotFoundException: Name mail is not
    at org.apache.naming.NamingContext.lookup(Na
    at org.apache.naming.NamingContext.lookup(Na
    at SendMailServlet.doPost(SendMailServlet.ja
    at javax.servlet.http.HttpServlet.service(Ht
    at javax.servlet.http.HttpServlet.service(Ht
    at org.apache.catalina.core.ApplicationFilte
    icationFilterChain.java:247)
    at org.apache.catalina.core.ApplicationFilte
    ilterChain.java:193)
    at org.apache.catalina.core.StandardWrapperV
    alve.java:243)
    at org.apache.catalina.core.StandardPipeline
    .java:566)
    at org.apache.catalina.core.StandardPipeline
    a:472)
    at org.apache.catalina.core.ContainerBase.in
    at org.apache.catalina.core.StandardContextV
    alve.java:215)
    at org.apache.catalina.core.StandardPipeline
    .java:566)
    at org.apache.catalina.core.StandardPipeline
    a:472)
    at org.apache.catalina.core.ContainerBase.in
    at org.apache.catalina.core.StandardContext.
    2366)
    at org.apache.catalina.core.StandardHostValv
    ava:164)
    at org.apache.catalina.core.StandardPipeline
    .java:566)
    at org.apache.catalina.valves.AccessLogValve
    462)
    at org.apache.catalina.core.StandardPipeline
    .java:564)
    at org.apache.catalina.core.StandardPipeline
    a:472)
    at org.apache.catalina.core.ContainerBase.in
    at org.apache.catalina.core.StandardEngineVa
    ve.java:163)
    at org.apache.catalina.core.StandardPipeline
    .java:566)
    at org.apache.catalina.core.StandardPipeline
    a:472)
    at org.apache.catalina.core.ContainerBase.in
    at org.apache.catalina.connector.http.HttpPr
    r.java:1005)
    at org.apache.catalina.connector.http.HttpPr
    va:1098)
    at java.lang.Thread.run(Thread.java:484)

    Thanks for your reply. I have changed in
    tomcat server.xml file, where it asks under
    smtp host name. I have listed the smtp host name
    there which I use to send the e-mail. I'm very new to this and if you can help me or point to some further resource, I'll appreciate your help. Thanks.

Maybe you are looking for

  • WON'T READ SD CARD (SANDISK)

    When I first put in the SD card and open it.  I went into the DCIM folder and it was able to see the pictures I had stored in it, but when I tried to pull it up again I could not see any file in the DCIM folder.  I was able go into the other folders

  • Grouping of Procurement elements for requirements lying in various months

    Dear all, Is there any Lot sizing procedure wherein only one Procurement Element (PR/ Planned Order) to be generated after the MRP run for the requirements lying in different months. With lot sizing procedure "MB" it is possible to group the PR gener

  • Unplanned delivery cost - miro

    Hi, how to post unplanned dleivery cost in miro?? i have Rs.3000  against a po.. how to post in miro??

  • Time Constraint Class

    What is the number (0 to 7) stands for time constraint class in absence for the screen number 2001. I have a leave type CL (causual leave). What time constraint class shall i assign to it. Regards, Chinmay

  • DVD button /chatper won't work on mac DVD player

    I have another weird thing going on... not sure if anyone would have an answer or not... My dvd plays fine on a standard dvd player (on a tv) and fine on a dvd player in a pc... But when i play it on a mac the dvd will not advance (only on a certian