Problem sending mail with SMTP and SSL

Hi,
I am trying to send mail using JavaMail 1.4/jdk1.5 using ssl. I save the certificate by going into IE and exporting the certificate and added the certificate using the keytool to ${JAVA_HOME}/jre/lib/security/cacerts.I have also added this in the code using
System.setProperty("javax.net.ssl.trustStore","${JAVA_HOME}/jre/lib/security/cacerts");But I am still getting the following error.
DEBUG SMTP: trying to connect to host "XXXX", port 465, isSSL true
DEBUG SMTP: exception reading response: javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
Exception in thread "main" javax.mail.MessagingException: Exception reading response;
  nested exception is:
     javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
     at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1462)
     at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1260)
     at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370)
     at javax.mail.Service.connect(Service.java:275)
     at glycomics.common.util.SendMailUsingAuthentication.postMail(Unknown Source)
     at glycomics.common.util.SendMailUsingAuthentication.main(Unknown Source)
Caused by: javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
     at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:166)
     at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1518)
     at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1485)
     at com.sun.net.ssl.internal.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1468)
     at com.sun.net.ssl.internal.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1394)
     at com.sun.net.ssl.internal.ssl.AppInputStream.read(AppInputStream.java:86)
     at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:97)
     at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
     at java.io.BufferedInputStream.read(BufferedInputStream.java:235)
     at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:75)
     at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1440)
     ... 5 more
Caused by: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
     at sun.security.validator.PKIXValidator.<init>(PKIXValidator.java:56)
     at sun.security.validator.Validator.getInstance(Validator.java:146)
     at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.getValidator(X509TrustManagerImpl.java:105)
     at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:167)
     at com.sun.net.ssl.internal.ssl.JsseX509TrustManager.checkServerTrusted(SSLContextImpl.java:320)
     at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:841)
     at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:106)
     at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:495)
     at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:433)
     at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:818)
     at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1030)
     at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:678)
     at com.sun.net.ssl.internal.ssl.AppInputStream.read(AppInputStream.java:75)
     ... 10 more
Caused by: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
     at java.security.cert.PKIXParameters.setTrustAnchors(PKIXParameters.java:183)
     at java.security.cert.PKIXParameters.<init>(PKIXParameters.java:103)
     at java.security.cert.PKIXBuilderParameters.<init>(PKIXBuilderParameters.java:87)
     at sun.security.validator.PKIXValidator.<init>(PKIXValidator.java:54)Has anybody faced similar problem??Any suggestions??
TIA
M
Message was edited by:
c@de-m@nkey

See SSLNOTES.txt and the JavaMail FAQ for debugging hints.
If you turn on all the debugging output and still can't figure it out,
you'll probably need to ask in some Java security forum. The
problem is occurring when making the connection using SSLSocket,
before any JavaMail code comes into play.

Similar Messages

  • Problem while sending a mail with smtp and ssl

    Hi all,
    I am new to java mail . I have downloaded one java program to send the mail. I have configured smt and port address.And my System firewall is also in off mode
    Still i am unable to send the mail
    The following code is my program 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.URLName;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeMessage;
    import com.sun.mail.smtp.SMTPSSLTransport;
      To use this program, change values for the following three constants,
        SMTP_HOST_NAME -- Has your SMTP Host Name
        SMTP_AUTH_USER -- Has your SMTP Authentication UserName
        SMTP_AUTH_PWD  -- Has your SMTP Authentication Password
      Next change values for fields
      emailMsgTxt  -- Message Text for the Email
      emailSubjectTxt  -- Subject for email
      emailFromAddress -- Email Address whose name will appears as "from" address
      Next change value for "emailList".
      This String array has List of all Email Addresses to Email Email needs to be sent to.
      Next to run the program, execute it as follows,
      SendMailUsingAuthentication authProg = new SendMailUsingAuthentication();
    public class SendMailUsingAuthentication
    //private static final String SMTP_HOST_NAME = "smtp.mail.yahoo.com";
         private static final String SMTP_HOST_NAME = "smtp.gmail.com";
      private static final String SMTP_AUTH_USER = "admijn.ramd";
      private static final String SMTP_AUTH_PWD  = "hairamu";
      private static final int SMTP_PORT  = 465;
      private static final String emailMsgTxt      = "Online Order Confirmation Message. Also include the Tracking Number.";
      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]", "[email protected]"};
      public static void main(String args[]) throws Exception
        SendMailUsingAuthentication smtpMailSender = new SendMailUsingAuthentication();
        smtpMailSender.postMail( emailList, emailSubjectTxt, emailMsgTxt, emailFromAddress);
      public void postMail( String recipients[ ], String subject,
                                String message , String from)
           try{
        boolean debug = false;
         //Set the host smtp address
    //  Set the host smtp address
         Properties props = new Properties();
         props.put("mail.transport.protocol", "smtp");
         props.put("mail.smtp.port", SMTP_PORT);
         props.put("mail.smtp.starttls.enable","true");
         props.put("mail.smtp.host", SMTP_HOST_NAME);
         props.put("mail.smtp.auth", "true");
          props.put("mail.smtp.socketFactory.port", SMTP_PORT);
         props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
          props.put("mail.smtp.socketFactory.fallback", "false");
          SecurityManager security = System.getSecurityManager();
         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.setText(message);
         msg.setSubject(subject);
         msg.setContent(message, "text/plain");
         Transport.send(msg);
         }catch (MessagingException e) {
              // TODO: handle exception
              e.printStackTrace();
    * SimpleAuthenticator is used to do simple authentication
    * when the SMTP server requires it.
    private class SMTPAuthenticator extends javax.mail.Authenticator
    public PasswordAuthentication getPasswordAuthentication()
         try{
    String username = SMTP_AUTH_USER;
    String password = SMTP_AUTH_PWD;
    System.out.println("username "+ username+" Password"+password);
    return new PasswordAuthentication(username, password);
         }catch (Exception e) {
         return null;
    And i am getting the following exceptions
    javax.mail.MessagingException: Exception reading response;
      nested exception is:
         javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
         at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1611)
         at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1369)
         at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:412)
         at javax.mail.Service.connect(Service.java:310)
         at javax.mail.Service.connect(Service.java:169)
         at javax.mail.Service.connect(Service.java:118)
         at javax.mail.Transport.send0(Transport.java:188)
         at javax.mail.Transport.send(Transport.java:118)
         at com.FutureSoft.org.SendingMail.SendMailUsingAuthentication.postMail(SendMailUsingAuthentication.java:123)
         at com.FutureSoft.org.SendingMail.SendMailUsingAuthentication.main(SendMailUsingAuthentication.java:70)
    Caused by: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
         at com.sun.net.ssl.internal.ssl.InputRecord.handleUnknownRecord(Unknown Source)
         at com.sun.net.ssl.internal.ssl.InputRecord.read(Unknown Source)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(Unknown Source)
         at com.sun.net.ssl.internal.ssl.AppInputStream.read(Unknown Source)
         at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:110)
         at java.io.BufferedInputStream.fill(Unknown Source)
         at java.io.BufferedInputStream.read(Unknown Source)
         at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:88)
         at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1589)
         ... 9 more                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    hi neuro11
    the following code is for sending mail its is working fine in my system, just change the
    SMTP_AUTH_USER = "tina.numi"; with u r email user name
    SMTP_AUTH_PWD = "abdcde"; u r gmail password
    emailFromAddress = "[email protected]"; ur gmail addres
    emailList = {"[email protected]"}; receipient list .
    and u must sure that u r internet is on and firewall should be off . some times firewall restricts you to communicate with gmail port number
    Please make u r firewall off and source code is
    package com.FutureSoft.org.SendingMail;
    Some SMTP servers require a username and password authentication before you
    can use their Server for Sending mail. This is most common with couple
    of ISP's who provide SMTP Address to Send Mail.
    This Program gives any example on how to do SMTP Authentication
    (User and Password verification)
    This is a free source code and is provided as it is without any warranties and
    it can be used in any your code for free.
    Author : Sudhir Ancha
    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.URLName;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeMessage;
    import com.sun.mail.smtp.SMTPSSLTransport;
      To use this program, change values for the following three constants,
        SMTP_HOST_NAME -- Has your SMTP Host Name
        SMTP_AUTH_USER -- Has your SMTP Authentication UserName
        SMTP_AUTH_PWD  -- Has your SMTP Authentication Password
      Next change values for fields
      emailMsgTxt  -- Message Text for the Email
      emailSubjectTxt  -- Subject for email
      emailFromAddress -- Email Address whose name will appears as "from" address
      Next change value for "emailList".
      This String array has List of all Email Addresses to Email Email needs to be sent to.
      Next to run the program, execute it as follows,
      SendMailUsingAuthentication authProg = new SendMailUsingAuthentication();
    public class SendMailUsingAuthentication
    //private static final String SMTP_HOST_NAME = "smtp.mail.yahoo.com";
         private static final String SMTP_HOST_NAME = "smtp.gmail.com";
      private static final String SMTP_AUTH_USER = "tina.numi";// gmail username
      private static final String SMTP_AUTH_PWD  = "abdcde";// gmail password
      private static final int SMTP_PORT  = 465;
      private static final String emailMsgTxt      = "Online Order Confirmation Message. Also include the Tracking Number.";
      private static final String emailSubjectTxt  = "Order Confirmation Subject";
      private static final String emailFromAddress = "[email protected]";// gmail id
      // 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);
      public void postMail( String recipients[ ], String subject,
                                String message , String from)
           try{
        boolean debug = false;
         //Set the host smtp address
    //  Set the host smtp address
         Properties props = new Properties();
         props.put("mail.transport.protocol", "smtp");
         props.put("mail.smtp.port", SMTP_PORT);
         props.put("mail.smtp.starttls.enable","true");
         props.put("mail.smtp.host", SMTP_HOST_NAME);
         props.put("mail.smtp.auth", "true");
          props.put("mail.smtp.socketFactory.port", SMTP_PORT);
         props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
          props.put("mail.smtp.socketFactory.fallback", "false");
          SecurityManager security = System.getSecurityManager();
         Authenticator auth = new SMTPAuthenticator();
         Session session = Session.getInstance(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.setText(message);
         msg.setSubject(subject);
         msg.setContent(message, "text/plain");
         Transport t = session.getTransport("smtps");
         try {
              t.connect(SMTP_HOST_NAME, SMTP_AUTH_USER, SMTP_AUTH_PWD);
              t.sendMessage(msg, msg.getAllRecipients());
         catch(Exception e){}
         finally
              t.close();
         }catch (MessagingException e) {
              // TODO: handle exception
              e.printStackTrace();
    * SimpleAuthenticator is used to do simple authentication
    * when the SMTP server requires it.
    private class SMTPAuthenticator extends javax.mail.Authenticator
    public PasswordAuthentication getPasswordAuthentication()
         try{
    String username = SMTP_AUTH_USER;
    String password = SMTP_AUTH_PWD;
    System.out.println("username "+ username+" Password"+password);
    return new PasswordAuthentication(username, password);
         }catch (Exception e) {
         return null;
    try this . all the best

  • I have a problem sending mail via smtp. I use a satellite system and the average return time for a ping is 675ms. Is this a problem with mail? If so can I change Mail to accept it. The problem also exists with Lion

    I have a problem sending mail via smtp. I use a satellite system and the average return time for a ping is 675ms. Is this a problem with mail? If so can I change Mail to accept it. The problem also exists with Lion and on both my MacPro and my wife's Imac. I also see my mailboxes randomly disconnecting and reconnecting. Any other ideas of a possible cause?

    I solved it myself, after the "note" which came back from FF/Mozilla just as I finished my message, commenting on what it was that my system had , I wnnt back to check my plug-ins etc. I downloaded the latest Java, BOTH 32bit AND 64 bit versions and latest Firefox.
    Now all is working.
    Thanks,
    B.

  • Problem sending mail with attachments???

    Hi Everybody,
    I have got a problem sending mail with attachments...
    I am able to send a plain mail ... but when i am trying to send mail along with an attachment ... its not being sent....
    its not showing any error it is simply hanging...
    what should i do?
    If u know any solns please do suggest me....
    Thanks in advance

    activation.jar is already there...
    initially i wrote a swing program as a front end and it was working abs fine... in my sense it was properly sending mails along with the attachments...
    when i changed the front-end to JSP handled by Servlets i am getting a problem...
    and even the swing program stopped working ...
    now swing program is getting compiled but it is hanging at run time showing an exception "Exception occured during event dispatching"
    i dont understand what probably may be the problem...
    if u can trace out, please give me any suggestions
    Thanks in advance and regards

  • Send mail with attachment and more recipients

    Hi to all,
    I have this procedure :
    PROCEDURE SPEDISCI_MAIL
    Mittente IN VARCHAR2,
    Destinatario IN VARCHAR2,
    Oggetto IN VARCHAR2,
    Messaggio IN VARCHAR2
    IS
    mailhost VARCHAR2(40) := 'pippo.com';
    conn utl_smtp.connection;
    crlf VARCHAR2( 2 ):= CHR( 13 ) || CHR( 10 );
    mesg VARCHAR2( 1000 );
    local_mittente VARCHAR2(2000) := mittente;
    BEGIN
    conn := utl_smtp.open_connection (mailhost,25);
    mesg:='Date:'||TO_CHAR(SYSDATE,'dd mon yy hh24:mi:ss')||crlf||
    'From:<'||mittente||'>'||crlf||
    'Subject:'||Oggetto||crlf||
    'To:'||destinatario||crlf||''
    ||crlf||messaggio;
    utl_smtp.helo(conn, mailhost);
    utl_smtp.mail(conn,local_mittente);
    utl_smtp.rcpt(conn,destinatario);
    utl_smtp.data(conn, mesg);
    utl_smtp.quit(conn);
    END;
    Can I send mail with attachment and more recipients?
    Thank you
    Silvia

    Consider using UTL_MAIL package:
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_mail.htm
    (Note: it's not installed and configured by default, but the scripts are supplied with the Oracle database, see documentation for instructions)

  • Sending mail with SMTP sends it twice

    I'm sending a text mail, and with my ISP's smtp server it works fine. With my employer's SMTP server, I get each mail that is sent twice. I'm not sure why but I know it's not a problem with the code because I've compared the code to the examples and also because it works fine with my ISP's SMTP server. If I use Outlook to send mail with my work SMTP server I get the emails only once. I saw on jGuru someone posted the same question with no response. Any ideas???
    Michael

    hi cunparis,
    I have same problem. I am sending single mail but some time I got 2 mails.and aslo according to sendmail logs the mails are in fact sent twice.I would like to add one more point that this is on HP-UX. So if you have solution share it with us. Thanks in advance.

  • Problem sending mail with roaming profile (Outlook 2010)

    Hello all,
    I hope you will be able to help me.
    Here's the problem I have with Outlook 2010:
    When a user opens a roaming profile on another
    PC or on his new
    PC, everything works perfectly except
    Outlook.
    Outlook opens normally with all email
    accounts, you can even see the email, no worries
    about that.
    But when we want to send an email, it
    gets stuck in the outbox.
    Some additional info:
         - In the account settings,
    you can test the account settings, it says
    that everything is working (sending and receiving)
         - The only way I found today to
    operate the account is to
    completely remove and reconfigure
         - There is an error message
    that says I can not write on the file C:\Users\UserName\AppData\Roaming\Microsoft\Outlook\accountName.pst
         - The problem occurs with
    all users, not just one in particular
         - The accounts are IMAP
         - Incoming emails work
    Thank you for your help.

    Hi Tim,
    This is a known issue in Outlook, we don't recommend using IMAP account with roaming profile.
    For more information, you might want to read this similar thread:
    https://social.technet.microsoft.com/Forums/office/en-US/f9b1bf03-d468-46e8-b40d-76fac11fd66c/outlook-2010-creates-new-imap-pst-files-at-random-and-cannot-send-mail-roaming-profiles-and-imap?forum=outlook
    Regards,
    Ethan Hua
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • Problem sending mail with authentication

    Please help as I've spent the last two days trying various things to solve my problem to no avail. I have been able to send email through the smtp server I have access to (just for interest, smtp.cs.stir.ac.uk), to email addresses in the same domain (e.g [email protected]) because the server does not require me to log in to do this - I can do it anonymously.
    My problem comes when I try to send an email outwith the cs.stir.ac.uk subdomain, (e.g [email protected]) because it requires me to login. So I set about learning about authenticating with smtp servers using the javamail package, and I found two methods of doing it, both of which threw a javax.mail.AuthenticationFailedException. I believe this exception is only thrown when a username or password is wrong and I can't understand it because I'm definitely using the same user/pass combo as I do to log into my webmail. The stack trace for the exception is:
    javax.mail.Service.connect(Service.java:264)
    javax.mail.Service.connect(Service.java:134)
    javax.mail.Service.connect(Service.java:86)
    com.sun.mail.smtp.SMTPTransport.connect(SMTPTransport.java:144)
    javax.mail.Transport.send0(Transport.java:150)
    javax.mail.Transport.send(Transport.java:80)
    EmailAuth.send(EmailAuth.java:80)
    EmailAuth.<init>(EmailAuth.java:40)
    EmailPanel.actionPerformed(EmailPanel.java:56)
    javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1764)
    javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1817)
    javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)
    javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
    javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
    java.awt.Component.processMouseEvent(Component.java:5093)
    java.awt.Component.processEvent(Component.java:4890)
    java.awt.Container.processEvent(Container.java:1566)
    java.awt.Component.dispatchEventImpl(Component.java:3598)
    java.awt.Container.dispatchEventImpl(Container.java:1623)
    java.awt.Component.dispatchEvent(Component.java:3439)
    java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450)
    java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)
    java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
    java.awt.Container.dispatchEventImpl(Container.java:1609)
    java.awt.Window.dispatchEventImpl(Window.java:1585)
    java.awt.Component.dispatchEvent(Component.java:3439)
    java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
    java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)
    java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
    java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
    java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
    And the code I'm using is:
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;
    import java.io.*;
    public class EmailAuth
         public String uname;
         public String pword;
      public EmailAuth(String host, String username, String password, String message,
                String subject, String from, String[] to) throws MessagingException {
                uname = username;
                pword = password;
                send(host, username, password, message, subject, from, to);
      public void send( String host, String username, String password, String message,
                String subject, String from, String[] to) throws MessagingException
        boolean debug = false;
         Properties props = new Properties();
         props.put("mail.smtp.host", host);
         props.put("mail.smtp.auth", "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[to.length];
        for (int i = 0; i < to.length; i++)
            addressTo[i] = new InternetAddress(to);
    msg.setRecipients(Message.RecipientType.TO, addressTo);
    // Setting the Subject and Content Type
    msg.setSubject(subject);
    msg.setContent(message, "text/plain");
    Transport.send(msg);
    private class SMTPAuthenticator extends javax.mail.Authenticator
    public PasswordAuthentication getPasswordAuthentication(String username, String password)
    return new PasswordAuthentication(username, password);
    Any help is greatly appreciated!!

    try logging in to the SMTP server with that username/pwd manually. i've done this in win32 using telnet...
    at the command prompt, enter "telnet mail.host.com 143", then from within telnet type "a1 login username password". the SMTP server should respond with something like "a1 OK LOGIN completed" if accepted. then, close the session by entering "a2 logout" (or just kill the telnet session).
    the exchange should look like this:
    telnet mail.host.com 143 * OK IMAP4rev1 server ready (3.0.14)
    a1 login username password
    a1 OK LOGIN completed
    a2 logout
    * BYE IMAP4rev1 Server logging out
    a2 OK LOGOUT completed
    Connection to host lost.
    peace
    bobD

  • Sending Mail with attachment and preserving the order of attachment

    Hi Everyone!!!!!!
    My requirement is to send Email with attachment in the same order as they were attached by Sender while composing the mail. I want to preserve order of attachment in the mail and when receiver open a mail, the attached files should be reflected in same order as it was on sender side. In my application,the documents being upload are already in my database. So, user just requires to mark the corresponding check box and enter the Sequence number for each attachment. When he clicks on "SEND" button, the Source file is first written from database to OS level and then files are attached from source available on OS . The attached file name could be anything. Based on the Sequence number file should be attached and send. My current code works fine,but problem it is that the Sequence number is not preserved in my attachment . However, when I traced the output of FOR Loop by inserting it in a table " temp_trace" I found that the Sequence is preserved in the order that I want. So, I think that uploaded files are written on the Operating system in same order but they are not attached in same order. Below is the sample code that is I am using to attach file in email. Here, the user_sequence is the sequence number entered by user.
    for i in (select case when user_sequence is not null
    then trim(to_char(user_sequence ,'09'))||'_'||file_name||'.pdf'
    else ||'_'||file_name||'.pdf' end file_name ,
    file_src,length(file_src) len,cd.doc_id,PRIORITY from
    MIM_CLIENT_DOCS CD,(select DOC_ID ,user_sequence from table P_DOC_AND_user_sequence ) TEMP_TAB
    WHERE CD.DOC_ID = TEMP_TAB.DOC_ID order by case when user_sequence is null then 1 else 0 end, file_name)
    loop
    insert into temp_trace values(i.file_name);
    L_OUT := UTL_FILE.FOPEN(v_oracle_dir,i.file_name,'wb',32760);
    end loop;
    I want my output as
    1_first attachment.txt
    2_second_attachment.docx
    3_abc.sql
    _xxx.txt  ------------------ When sequence is not assigned by user That is null at last.
    Unfortunately, I am not getting attachment in mail in this sequence. Can anyone give me suggestion.
    Sorry for stuff essay and thanks in advance!!!!!!!!!!!

    >
    Please update your forum profile with a real handle instead of "974850".
    My requirement is to send Email with attachment in the same order as they were attached by Sender while composing the mail. I want to preserve order of attachment in the mail and when receiver open a mail, the attached files should be reflected in same order as it was on sender side. In my application,the documents being upload are already in my database. So, user just requires to mark the corresponding check box and enter the Sequence number for each attachment. When he clicks on "SEND" button, the Source file is first written from database to OS level and then files are attached from source available on OS . The attached file name could be anything. Based on the Sequence number file should be attached and send. My current code works fine,but problem it is that the Sequence number is not preserved in my attachment . However, when I traced the output of FOR Loop by inserting it in a table " temp_trace" I found that the Sequence is preserved in the order that I want. So, I think that uploaded files are written on the Operating system in same order but they are not attached in same order. Below is the sample code that is I am using to attach file in email. Here, the user_sequence is the sequence number entered by user.Always post code using <tt>\...\</tt> tags as described in the FAQ.
    for i in (select case when  user_sequence is not null
    then trim(to_char(user_sequence ,'09'))||'_'||file_name||'.pdf'
    else  ||'_'||file_name||'.pdf' end file_name ,
    file_src,length(file_src) len,cd.doc_id,PRIORITY from
    MIM_CLIENT_DOCS CD,(select DOC_ID ,user_sequence from table P_DOC_AND_user_sequence ) TEMP_TAB
    WHERE CD.DOC_ID = TEMP_TAB.DOC_ID order by case when user_sequence is null then 1 else 0 end, file_name)                               
    loop
    insert into temp_trace values(i.file_name);
    L_OUT := UTL_FILE.FOPEN(v_oracle_dir,i.file_name,'wb',32760);
    end loop;I want my output as
    1_first attachment.txt
    2_second_attachment.docx
    3_abc.sql
    _xxx.txt  ------------------ When sequence is not assigned by user That is null at last.
    Unfortunately, I am not getting attachment in mail in this sequence. Can anyone give me suggestion.I see no code that attaches anything to email messages. What code is used to do this? Why are the files being written to the file system?

  • Sending mail with attachment and body.

    Hi Experts,
    I have a requirement of sending a mail with an attachment and also the mail will have a body whose content will be same as that in the attachment.Subject of the mail will also be configured dynamically.Though I am able to send the mail with the attachment but I am not able to configure the body whose content will be same as that of the attachment.
    I have unchecked the "Use Mail Package" and has hard-coded the "TO","From" field for sending the mail with attachment.
    Can you please check and let me know how to configure the body which will be same as that of the attachment.
    Thanks and Regards
    Atanu Mazumdar

    Hi,
    Use MTB module and then one of the parameter which can allow you to send message in attachment as well as in message body.
    Transform.ContentDisposition: it helps us to decide if we want to send the payload as an attachment or in the message body. If we give the Parameter value as u201Cattachmentu201D then we will have the payload attached in the mail and if we assign this value as u201Cinlineu201D the payload will go in the mail body.
    Hope this helps you..
    Regards....

  • Problems sending mail with Exchange SBS 2003 / apple mail

    Here is an odd one. I can easily sync up with the exchange server at my office using my mac. I can view new mail, view sent mail and drafts easily.
    When sending e-mail, it is a crap-shoot if it actually will send it or not. Sometimes it goes through, but the majority of the time it does not. I get delay messages from the server, and ultimately I get the "failed to send" message. But the mail is getting to the exchange server because I can see it in the queue.
    Through Parallels, I was able to successfully configure and run Outlook 2004. When testing the same e-mail addresses, the Outlook mail went through easily, but the apple mail stalled and eventually failed.
    On top of this, I can send e-mails to certain domains without ever getting an error through apple mail (i.e. a local company, hotmail.com, etc). Whereas others always or most of the time give me errors (cox.net, yahoo.com, another local company).
    I checked the message queue on the exchange server and sure enough they were stuck trying to resend every 5 minutes - with no luck. There has to be a security setting or something preventing me from being able to send mail through my apple mail app.

    This was an issue with my Exchange server.

  • Sending mail with Cc and copy in sent message box

    Since I have the last OS X 10.6.6 update, I dont receive anymore the Cc copy which I send to myself
    and have only the copy of the sent message in the sent box (messages envoyés)
    Similarly I cannot send a mail to myself as a verification process of my external mail provider. The copy is stored in the sent copy box, but it doesnt arrive in the in box (boite de reception)
    How can I get back to the former situation in which I could send copies to myself or send mail to myself
    Thanks for any hint
    Claude

    The first exception is this:
    http://java.sun.com/products/javamail/FAQ.html#norelay
    The second exception is probably due to a configuration error
    on the client. Turn on session debugging and the protocol
    trace will give some clues about what's wrong with the HELO
    command.

  • Send Mail with xls AND pdf as attachment

    Hi there!
    I would lke to write a little program, which is able to send a xls-file AND a pdf-file within one mail.
    xls alone is already working fine, I'm using the method add_attachment of the class cl_document_bcs. But now I also want to add a pdf-File to this mail. The pdf file is on the local disk, so I'm uploading it via 'GUI_UPLOAD'. But now I have a problem because I don't know how I am able to add this to the mail.
    I hope you can help me!!
    Greetings,
    littlesam

    Hi,
    here a short extract:
    DATA: IT_BIN    TYPE SOLIX_TAB.
    DATA: WA_BIN    TYPE SOLIX.
    DATA: IT_LENGHT TYPE SO_OBJ_LEN.
    DATA: N10(10)   TYPE N.
    DATA: DOCUMENT  TYPE REF TO CL_DOCUMENT_BCS.
    DATA: WA_BCS    TYPE REF TO CX_BCS.
    DATA: ATT_TYPE  TYPE SOODK-OBJTP.
    DATA: SUBJECT   TYPE SO_OBJ_DES.
    DATA: P_FILE    LIKE RLGRAP-FILENAME VALUE 'C:\TEST.PDF'.
    DATA: FILE_NAME TYPE STRING.
    DATA: FILE_PATH LIKE PCFILE-PATH.
    *UPLOAD
    FILE_NAME = P_FILE.
    FILE_PATH = P_FILE.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
      EXPORTING
        FILENAME = FILE_NAME
        FILETYPE = 'BIN'
      CHANGING
        DATA_TAB = IT_BIN[].
    CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
      EXPORTING
        COMPLETE_FILENAME = FILE_PATH
      IMPORTING
        EXTENSION         = ATT_TYPE
        NAME              = SUBJECT.
    * ATTACHMENT
    DESCRIBE TABLE IT_BIN LINES N10.
    READ TABLE IT_BIN INDEX N10 INTO WA_BIN.
    N10 = ( N10 - 1 ) * 255 + STRLEN( WA_BIN ).
    IT_LENGHT = N10.
    TRY.
        CALL METHOD DOCUMENT->ADD_ATTACHMENT
          EXPORTING
            I_ATTACHMENT_TYPE    = ATT_TYPE
            I_ATT_CONTENT_HEX    = IT_BIN
            I_ATTACHMENT_SIZE    = IT_LENGHT
            I_ATTACHMENT_SUBJECT = SUBJECT.
    * Error abfangen
      CATCH CX_BCS INTO WA_BCS.
        WRITE: 'Fehler aufgetreten.'(001).
        WRITE: 'Fehlertyp:'(002), WA_BCS->ERROR_TYPE.
        EXIT.
    ENDTRY.
    You can use it for every local file
    Hope it helps.
    regards, Dieter

  • Problem sending mail with ATTATCHMENTS

    hi all,
    Im doing something like this to send a mail with attatchments:
         msg.setRecipients(Message.RecipientType.TO, address);
         msg.setSubject(subj);
         MimeBodyPart textPart = new MimeBodyPart();
         textPart.setContent(text, "text/plain");
         File f = new File(filename);     
         MimeBodyPart attachFilePart = new MimeBodyPart();
         FileDataSource fds = new FileDataSource(f);
         attachFilePart.setDataHandler(new DataHandler(fds));
         attachFilePart.setFileName(fds.getName());
         Multipart mp = new MimeMultipart();
         mp.addBodyPart(textPart);
         mp.addBodyPart(attachFilePart);
         msg.setContent(mp);
         Transport.send(msg);
    this is working for the first time........
    if I execute this for the second time.... my attatchments are visibile inside the message..... something like this...
    ------=_Part_28_1086341.1034758766530
    sd
    <br>fa
    <br>sdf
    <br>sd
    <br>
    ------=_Part_28_1086341.1034758766530
    Content-Disposition: attachment; filename="2day's Work.txt"
    Today's tasks done:
    OCR conversion for the following:
    1) pages rescaned in 12th class part A.
    2) pages 61- in 12th class part C.
    ------=_Part_28_1086341.1034758766530--
    it is showing the attatchment content inside when i run the same code for the second time....
    anyone can help me out!!!
    thax in adv,
    kiran

    yup.. it worked navaz.....
    thx a lot... may i know whatz happening here...
    thx again...
    kiran

  • HT4864 Mail client can't send mail with @me and @icloud

    Why my mail account @icloud or @me don't work well with my mai client (windows live mail 2012)? I've setted the right parameters, but i can only recive the email, when i try to send it the account don't work! I've setted the mail client with this parameters:
    IMAP (Incoming Mail Server) information:
    Server name: imap.mail.me.com
    SSL Required: Yes
    Port: 993
    Username: [email protected] (use your @me.com address from your iCloud account)
    Password: Your iCloud password
    SMTP (outgoing mail server) information:
    Server name: smtp.mail.me.com
    SSL Required: Yes
    Port: 587
    SMTP Authentication Required: Yes
    Username: [email protected] (use your @me.com address from your iCloud account)
    Password: Your iCloud password

    The following link may provide help...
    http://apple.stackexchange.com/questions/35350/how-can-i-add-my-icloud-email-acc ount-in-windows-live-mail

Maybe you are looking for