Issue  while sending mails using classes

Hi Experts ,
i have one issue when i try to send mails using classes cl_document_bcs,cl_cam_address_bcs,cl_bcs etc
ISSUE :
i put some data in selection screen and i get some output ( say i got 5 records), i select 3 records and press some button to trigger mail and mail is send, and now again the OUTPUT screen is  shown with  sended records but we can not send these records again ............ now i selcect remaining two records  and press button to trigger mail and THIS TIME MAIL IS NOT SEND.
amd my code is :
CREATE OBJECT l_document.
  CREATE OBJECT l_recipient.
  TRY.
      cl_bcs_convert=>string_to_solix(
      EXPORTING
      iv_string = fp_wa_output
      iv_codepage = fp_v_code_page
      iv_add_bom = 'X'
      IMPORTING
      et_solix = l_wa_output_binary
      ev_size = l_v_size ).
      l_send_request = cl_bcs=>create_persistent( ).
*-->Creating Document
      l_document = cl_document_bcs=>create_document(
      i_type = 'RAW'
      i_text = fp_it_content[]
      i_subject = fp_text_48 ) .
*-->Adding Attachment*
      CALL METHOD l_document->add_attachment
        EXPORTING
          i_attachment_type    = fp_text_049
          i_attachment_size    = l_v_size
          i_attachment_subject = fp_v_file
          i_att_content_hex    = l_wa_output_binary.
*-->Add document to send request*
      CALL METHOD l_send_request->set_document( l_document ).
*    do send delivery info for successful mails
      CALL METHOD l_send_request->set_status_attributes
        EXPORTING
          i_requested_status = 'E'
          i_status_mail      = 'A'.
*-->Get Sender Object
      l_uname = sy-uname.
      l_sender = cl_sapuser_bcs=>create( l_uname ).
      CALL METHOD l_send_request->set_sender
        EXPORTING
          i_sender = l_sender.
      LOOP AT fp_s_mail INTO l_wa_mail.
        l_v_objid = l_wa_mail-low.
        l_v_mail = l_v_smtpadr.
        TRANSLATE l_v_mail TO LOWER CASE.
        l_recipient = cl_cam_address_bcs=>create_internet_address( l_v_mail ).
        CALL METHOD l_send_request->add_recipient
          EXPORTING
            i_recipient  = l_recipient
            i_express    = 'X' .
*            i_copy       = ' '
*            i_blind_copy = ' '
*            i_no_forward = ' '.
      ENDLOOP.
**-->Trigger E-Mail immediately*
*      IF fp_send_all EQ 'X'.
*        l_send_request->set_send_immediately( 'X' ).
*      ENDIF.
      CALL METHOD l_send_request->send(
      EXPORTING
      i_with_error_screen = 'X'
        RECEIVING result = l_v_sent_to_all ).
      BREAK TARK.
      IF l_v_sent_to_all = 'X'.
        MESSAGE i000 .
      ENDIF.
    COMMIT WORK.
    CATCH cx_document_bcs INTO l_bcs_exception.
    CATCH cx_send_req_bcs INTO l_send_exception.
    CATCH cx_address_bcs INTO l_addr_exception.
    CATCH cx_bcs INTO l_exp.
  ENDTRY.
thanks in advance
rahul

Every time when i choose other network or dongle to send those mails it gets sent.
As per the description, seems it's an issue related to this specific network. Probably, they've adjusted their security policy, like blocked some port numbers, etc.
You might need to contact the support of your ISP to confirm what SMTP settings you need. Check port number, and security settings.
By the way, this is the forum to discuss questions and feedback for Windows-based Microsoft Office client. Since your query is directly related to
Office for mac, I would suggest you to post in the forum of
Office for Mac, where you can get more experienced responses:
http://answers.microsoft.com/en-us/mac/forum/macoffice2011?tab=Threads
The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
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.

Similar Messages

  • Send mail using class

    Hi,
    I need to send PDF files as attachment to a mail using Classes.
    Is there a way to do it ?
    Thanks.
    David

    Hi,
    I have develop this code to send multiple HTML attachments using CL_BCS class
    Form f_send_html_mail.
      data: send_request       type ref to cl_bcs.
      data: document           type ref to cl_document_bcs.
      data: sender             type ref to cl_sapuser_bcs.
      data: recipient          type ref to if_recipient_bcs.
      data: exception_info     type ref to if_os_exception_info,
      bcs_exception            type ref to cx_document_bcs.
      data i_attachment_size type sood-objlen.
      data v_status          type bcs_stml.
      data v_request_status  type bcs_rqst.
      data : v_desc like sopcklsti1-obj_descr.
          concatenate 'Doc-' pdocno into v_desc.
          condense v_desc no-gaps.
          submit yttcr0001 exporting list to memory
                   with p_docno = pdocno
                   and return.
        call function 'LIST_FROM_MEMORY'
          tables
            listobject = report_list
          exceptions
            not_found  = 1
            others     = 2.
        call function 'WWW_HTML_FROM_LISTOBJECT'
          exporting
            template_name = 'WEBREPORTING_REPORT'
          tables
            html          = report_html
            listobject    = report_list.
        describe table objbin lines tab_lines.
        v_lines = tab_lines + 1.
        loop at report_html.
          move report_html to it_attach1.
          append it_attach1.
        endloop.
      send_request = cl_bcs=>create_persistent( ).
      try.
          document = cl_document_bcs=>create_document(
                                        i_type    = 'RAW'
                                        i_text = it_content[]
                                        i_subject = subject ).
          if not attach_name1 is initial.
            call method document->add_attachment
              exporting
                i_attachment_type    = attach_ext1
                i_attachment_subject = attach_name1
                i_att_content_text   = it_attach1[].
          endif.
         "<<< if you want multiple attachment then use this
          if not attach_name2 is initial.
            call method document->add_attachment
              exporting
                i_attachment_type    = attach_ext2
                i_attachment_subject = attach_name2
                i_att_content_text   = it_attach2[].
          endif.
          call method send_request->set_document( document ).
          sender = cl_sapuser_bcs=>create( sy-uname ).
          call method send_request->set_sender
            exporting
              i_sender = sender.
          loop at it_recipient.
            translate it_recipient-smtp_addr to lower case.
            recipient = cl_cam_address_bcs=>create_internet_address( it_recipient-smtp_addr ).
            call method send_request->add_recipient
              exporting
                i_recipient  = recipient
                i_express    = ' '
                i_copy       = ' '
                i_blind_copy = ' '
                i_no_forward = ' '.
          endloop.
          move : 'E' to v_request_status.
          v_status = v_request_status.
          call method send_request->set_status_attributes
            exporting
              i_requested_status = v_request_status
              i_status_mail      = v_status.
          call method send_request->send( ).
          commit work.
        catch cx_document_bcs into bcs_exception.
      endtry.
    endform.                               
    and also check this link
    /people/thomas.jung3/blog/2005/01/05/develop-a-web-service-that-sends-an-email--in-abap
    aRs

  • Error while sending mail using script task in ssis 2008

    Hi,
        i am trying to send mail using ssis 2008 script task.for my requirement i am not able to use send mail task.
    code i have used is
    declared read only variables system::packagename
     Dim PACKAGE As String
            PACKAGE = Dts.Variables("System::PackageName").Value.ToString()
            Dim myHtmlMessage As MailMessage
            Dim mySmtpClient As SmtpClient
            myHtmlMessage = New MailMessage("[email protected]", "[email protected]", "PACKAGE STATUS", PACKAGE + "WAS FAILED")
         mySmtpClient = New SmtpClient("smtp.gmail.com")
            mySmtpClient.Credentials = New NetworkCredential("[email protected]", "mypassword")
            mySmtpClient.EnableSsl = True
            mySmtpClient.Port = 587
            mySmtpClient.Send(myHtmlMessage)
    error i am getting is
    Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1
    Authentication Required. Learn more at
       at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response)
       at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, String from)
       at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
       at System.Net.Mail.SmtpClient.Send(MailMessage message)
       at ST_c121e07caaa94c21bb1355d4f753112f.vbproj.ScriptMain.Main()
       --- End of inner exception stack trace ---
       at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
       at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture)
       at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()
    can any one tell me where i am going wrong

    also getting error as follows
    Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1
    Authentication Required. Learn more at
       at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response)
       at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, String from)
       at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
       at System.Net.Mail.SmtpClient.Send(MailMessage message)
       at ST_c121e07caaa94c21bb1355d4f753112f.vbproj.ScriptMain.Main()
       --- End of inner exception stack trace ---
       at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
       at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture)
       at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()

  • SMICM error while sending mail using SMTP server

    Hi All,
    We are not able send mails using SMTP server.
    We have made every settings necessary in SCOT, SO16 , SMTP service is activated, default domain is maintained etc
    Only things which seems to be wrong is in SMICM trace file.
    [Thr 13] *** ERROR => NiBufIConnect: non-buffered connect pending after 5000ms (hdl 29;10.26.24.44:1090) [nibuf.cpp    4608]
    [Thr 13] *** WARNING => Connection request from (0/1/0) to host: 10.26.24.44, service: 1090 failed (NIECONN_REFUSED)
    [icxxconn_mt.c 2321]
    This error is getting repeated in it.
    BUt I am not sure why it it trying to hit 10.26.24.44, as we dont have any server by this ip. The ip is only not resolvable from the server.
    1 more thing, at OS level, following parameter is maintained in profile :
    icm/server_port_1 = PROT=SMTP,PORT=25000,TIMEOUT=180
    But in SCOT, under SMTP node PORT is given as 25.
    Kindly let me know what going wrong here?
    Thanks

    also getting error as follows
    Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1
    Authentication Required. Learn more at
       at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response)
       at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, String from)
       at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
       at System.Net.Mail.SmtpClient.Send(MailMessage message)
       at ST_c121e07caaa94c21bb1355d4f753112f.vbproj.ScriptMain.Main()
       --- End of inner exception stack trace ---
       at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
       at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture)
       at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()

  • Getting exceptions while sending mail using javamail api

    Hi to all
    I am developing an application of sending a mail using JavaMail api. My program is below:
    quote:
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;
    public class sms
    public static void main(String args[])
    try
    String strstrsmtserver="smtp.bol.net.in";
    String strto="[email protected]";
    String strfrom="[email protected]";
    String strsubject="Hello";
    String bodytext="This is my first java mail program";
    sms s=new sms();
    s.send(strstrsmtserver,strto,strfrom,strsubject,bodytext);
    catch(Exception e)
    System.out.println("usage:java sms"+"strstrsmtpserver tosddress fromaddress subjecttext bodyText");
    System.exit(0);
    public void send(String strsmtpserver,String strto,String strfrom ,String strsubject,String bodytext)
    try
    java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
    Properties p=new Properties(System.getProperties());
    if(strsmtpserver!=null)
    p.put("mail.transport.protocol","smtp");
    p.put("mail.smtp.host","[email protected]");
    p.put("mail.smtp.port","25");
    Session session=Session.getDefaultInstance(p);
    Message msg=new MimeMessage(session);
    Transport trans = session.getTransport("smtp");
    trans.connect("smtp.bol.net.in","[email protected]","1234563757");
    msg.setFrom(new InternetAddress(strfrom));
    msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(strto,false));
    msg.setSubject(strsubject);
    msg.setText(bodytext);
    msg.setHeader("X-Mailer","mtnlmail");
    msg.setSentDate(new Date());
    Transport.send(msg);
    System.out.println("Message sent OK.");
    catch(Exception ex)
    System.out.println("here is error");
    ex.printStackTrace();
    It compiles fine but showing exceptions at run time.Please help me to remove these exceptions.I am new to this JavaMail and it is my first program of javamail.Please also tell me how to use smtp server.I am using MTNL 's internet connection having smtp.bol.net.in server.
    exceptions are:
    Here is exception
    quote:
    Javax.mail.MessagingException:Could not connect to SMTP host : smtp.bol.net.in, port :25;
    Nested exception is :
    Java.net.ConnectException:Connection refused: connect
    At com.sun.mail.smtp.SMTPTransport.openServer<SMTPTransport.java:1227>
    At com.sun.mail.smtp.SMTPTransport.protocolConnect<SMTPTransport.java:322>
    At javax.mail.Service .connect(Service.java:236>
    At javax.mail.Service.connect<Service.java:137>
    At sms.send<sms.java:77>
    At sms.main<sms.java:24>

    Did you find the JavaMail FAQ?
    You should talk to your ISP to get the details for connecting to your server.
    In this case I suspect your server wants you to make the connection on the
    secure port. The FAQ has examples of how to do this for GMail and Yahoo
    mail, which work similarly. By changing the host name, these same examples
    will likely work for you.

  • Problems while sending mail using java mail

    hi all,
    the following are the errors i get while sending a mail from my smtp local host-
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;
    import javax.mail.Authenticator;
    import javax.mail.PasswordAuthentication;
    public class SendEmail
         public static void main(String[] args)
    System.out.println(args.length);
              if (args.length != 6)
                   System.out.println("usage: sendmessage <to> <from> <smtphost> <true|false> <subject> <text>");
                   System.exit(1);System.out.println("jj"+args.length);
         SendEmail m=new SendEmail();
         m.SendMessage(args[0],args[1], args[2], args[3], args[4], args[5]);
    public static String SendMessage(String emailto, String emailfrom, String smtphost, String emailmultipart, String msgSubject, String msgText)
    boolean debug = false; // change to get more information
    String msgText2 = "multipart message";
    boolean sendmultipart = Boolean.valueOf(emailmultipart).booleanValue();
    // set the host
    Properties props = new Properties();
    props.put("mail.smtp.host",smtphost);
         props.put("mail.smtp.starttls.enable","true");
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.sendpartial", "true");
    Authenticator loAuthenticator = new SMTPAuthenticator();
    System.out.println("f");
    // create some properties and get the default Session
    Session session = Session.getDefaultInstance(props, loAuthenticator );
    session.setDebug(debug);
    try
    // create a message
    Message msg = new MimeMessage(session);
    // set the from
    InternetAddress from = new InternetAddress(emailfrom);
    msg.setFrom(from);
    InternetAddress[] address =
    new InternetAddress(emailto)
    //InternetAddress ad=new InternetAddress(session);
    msg.setRecipients(Message.RecipientType.TO, address);
    System.out.println("fc");
    msg.setSubject(msgSubject);
    System.out.println("fvf");
    if(!sendmultipart)
    // send a plain text message
    msg.setContent(msgText, "text/plain");
    System.out.println("fif");
    else
    System.out.println("felsd");
    // send a multipart message// create and fill the first message part
    MimeBodyPart mbp1 = new MimeBodyPart();
    mbp1.setContent(msgText, "text/plain");
    // create and fill the second message part
    MimeBodyPart mbp2 = new MimeBodyPart();
    mbp2.setContent(msgText2, "text/plain");
    // create the Multipart and its parts to it
    Multipart mp = new MimeMultipart();
    mp.addBodyPart(mbp1);
    mp.addBodyPart(mbp2);
    // add the Multipart to the message
    msg.setContent(mp);
    Transport transport = session.getTransport("smtp");
         transport.connect(smtphost,"[email protected]","xyz");
    msg.saveChanges();
    System.out.println("fconn");
              //transport.sendMessage(msg,msg.getAllRecipients());
    transport.sendMessage(msg,msg.getAllRecipients());
    transport.close();     
    //Transport.send(msg);
    catch(MessagingException mex)
    mex.printStackTrace();
    return "Email sent to " + emailto;
    class SMTPAuthenticator extends Authenticator
    public PasswordAuthentication getPasswordAuthentication()
    String username = "[email protected]";
    String password = "xyz";
    return new PasswordAuthentication(username, password);
    i dont understand what the problem is..inspite of having the right code..
    i guess some firewall problem..
    can somebody help me please..il be highly obliged..thanks..

    hi all,
    the following are the errors i get while sending a mail from my smtp local host-
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;
    import javax.mail.Authenticator;
    import javax.mail.PasswordAuthentication;
    public class SendEmail
         public static void main(String[] args)
    System.out.println(args.length);
              if (args.length != 6)
                   System.out.println("usage: sendmessage <to> <from> <smtphost> <true|false> <subject> <text>");
                   System.exit(1);System.out.println("jj"+args.length);
         SendEmail m=new SendEmail();
         m.SendMessage(args[0],args[1], args[2], args[3], args[4], args[5]);
    public static String SendMessage(String emailto, String emailfrom, String smtphost, String emailmultipart, String msgSubject, String msgText)
    boolean debug = false; // change to get more information
    String msgText2 = "multipart message";
    boolean sendmultipart = Boolean.valueOf(emailmultipart).booleanValue();
    // set the host
    Properties props = new Properties();
    props.put("mail.smtp.host",smtphost);
         props.put("mail.smtp.starttls.enable","true");
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.sendpartial", "true");
    Authenticator loAuthenticator = new SMTPAuthenticator();
    System.out.println("f");
    // create some properties and get the default Session
    Session session = Session.getDefaultInstance(props, loAuthenticator );
    session.setDebug(debug);
    try
    // create a message
    Message msg = new MimeMessage(session);
    // set the from
    InternetAddress from = new InternetAddress(emailfrom);
    msg.setFrom(from);
    InternetAddress[] address =
    new InternetAddress(emailto)
    //InternetAddress ad=new InternetAddress(session);
    msg.setRecipients(Message.RecipientType.TO, address);
    System.out.println("fc");
    msg.setSubject(msgSubject);
    System.out.println("fvf");
    if(!sendmultipart)
    // send a plain text message
    msg.setContent(msgText, "text/plain");
    System.out.println("fif");
    else
    System.out.println("felsd");
    // send a multipart message// create and fill the first message part
    MimeBodyPart mbp1 = new MimeBodyPart();
    mbp1.setContent(msgText, "text/plain");
    // create and fill the second message part
    MimeBodyPart mbp2 = new MimeBodyPart();
    mbp2.setContent(msgText2, "text/plain");
    // create the Multipart and its parts to it
    Multipart mp = new MimeMultipart();
    mp.addBodyPart(mbp1);
    mp.addBodyPart(mbp2);
    // add the Multipart to the message
    msg.setContent(mp);
    Transport transport = session.getTransport("smtp");
         transport.connect(smtphost,"[email protected]","xyz");
    msg.saveChanges();
    System.out.println("fconn");
              //transport.sendMessage(msg,msg.getAllRecipients());
    transport.sendMessage(msg,msg.getAllRecipients());
    transport.close();     
    //Transport.send(msg);
    catch(MessagingException mex)
    mex.printStackTrace();
    return "Email sent to " + emailto;
    class SMTPAuthenticator extends Authenticator
    public PasswordAuthentication getPasswordAuthentication()
    String username = "[email protected]";
    String password = "xyz";
    return new PasswordAuthentication(username, password);
    i dont understand what the problem is..inspite of having the right code..
    i guess some firewall problem..
    can somebody help me please..il be highly obliged..thanks..

  • Java Session problem while sending mail(using javamail) using Pl/SQL

    Hello ...
    i am using Java stored procedure to send mail. but i'm getting java session problem. means only once i can execute that procedure
    pls any help.

    props.put("smtp.gmail.com",host);I doubt javamail recognizes the 'smtp.gmail.com' property. I think it expects 'mail.host'. Of course since it cannot find a specified howt it assumes by default localhost
    Please format your code when you post the next time, there is a nice 'code' button above the post area.
    Mike

  • Exception while sending mail using javamail

    below i am using the code to send a mail to [email protected]
    but it is giving exception
    "class com.sun.mail.smtp.SMTPSendFailedException: 554 <[email protected]>: Recipient address rejected: Relay access denied"
    please can any body help me to solve this problem
    Properties props = new Properties();
    props.put("mail.smtp.host", "xxxxxxxxxxxxx");
    Session s = Session.getInstance(props,null);
    MimeMessage message = new MimeMessage(s);
    InternetAddress from = new InternetAddress("[email protected]");
    message.setFrom(from);
    InternetAddress to = new InternetAddress("[email protected]");
    message.addRecipient(Message.RecipientType.TO, to);
    message.setSubject("Test from JavaMail.");
    message.setText("Hello from JavaMail!");
    Transport.send(message);

    I was getting the same error as the others, and I added authentication, but it still gives me the error.
    All "AutomailingUtility" constants are strings
    public class SMTPSender {
    private Session session;
    public SMTPSender() {
    Properties props = new Properties();
    props.setProperty("mail.smtp.host", AutomailingUtility.HOST);
    props.put("mail.smtp.auth", AutomailingUtility.AUTH);
    Authenticator auth = new MyAuthenticator(AutomailingUtility.USERNAME, AutomailingUtility.PASSWORD);
    session = Session.getInstance(props, auth);
    public void sendMessage(String toUser, String message, String subject) {
    try {
    Message msg = new MimeMessage(session);
    msg.setSubject(subject);
    msg.setSentDate(new Date());
    InternetAddress ia = new InternetAddress(AutomailingUtility.FROM_ADDRESS);
    msg.setFrom(ia);
    msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(toUser));
    msg.setText(message);
    Transport.send(msg);
    } catch (AddressException e) {
    e.printStackTrace();
    } catch (MessagingException e) {
    e.printStackTrace();
    any ideas?

  • Problems while sending mail using java mail..help...

    Hello all,
    I am new to Java Mail...
    Below is my first program...
    Can anybody tell what's wrong in it..??
    Thanks in advance....
    ------------------------------------------------------start--------------------
    package test;
    import java.util.Properties;
    import javax.mail.Address;
    import javax.mail.Authenticator;
    import javax.mail.MessagingException;
    import javax.mail.NoSuchProviderException;
    import javax.mail.PasswordAuthentication;
    import javax.mail.Session;
    import javax.mail.Transport;
    import javax.mail.Message.RecipientType;
    import javax.mail.internet.AddressException;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeMessage;
    public class Send
         public Send()
         public void send()
              java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
              Properties props=new Properties();
              props.put("mail.transport.protocol", "smtp");
              props.put("mail.smtp.host","smtp.gmail.com");
              props.put("mail.smtp.port","25");
              props.put("mail.smtp.auth","true");
              Session session=Session.getDefaultInstance(props,new MyAuthenticator());
              session.setDebug(true);
              MimeMessage message=new MimeMessage(session);
              try
                   message.setContent("Hello ...","text/plain");
                   message.setSubject("Test mail...plz don't ignore..");
                   Address to=new InternetAddress("[email protected]");
                   Address from=new InternetAddress("[email protected]");
                   Address replyTo=new InternetAddress("[email protected]");
                   message.setFrom(from);
                   message.setReplyTo(new Address[]{replyTo});
                   message.setRecipient(RecipientType.TO,to);               
                   Transport.send(message);
              } catch (AddressException e)
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (NoSuchProviderException e)
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (MessagingException e)
                   // TODO Auto-generated catch block
                   e.printStackTrace();
         public static void main(String[] args)
              new Send().send();          
         class MyAuthenticator extends Authenticator
              MyAuthenticator()
                   super();
              protected PasswordAuthentication getPasswordAuthentication()
                   return new PasswordAuthentication("[email protected]", "*******");
    --------------------------------------------end--------------
    here is the output.....
    DEBUG: setDebug: JavaMail version 1.3.2
    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 "smtp.gmail.com", port 25, isSSL false
    220 mx.gmail.com ESMTP 16sm2443823wrl
    DEBUG SMTP: connected to host "smtp.gmail.com", port: 25
    EHLO jijo
    250-mx.gmail.com at your service
    250-SIZE 20971520
    250-8BITMIME
    250-STARTTLS
    250 ENHANCEDSTATUSCODES
    DEBUG SMTP: Found extension "SIZE", arg "20971520"
    DEBUG SMTP: Found extension "8BITMIME", arg ""
    DEBUG SMTP: Found extension "STARTTLS", arg ""
    DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
    DEBUG SMTP: use8bit false
    MAIL FROM:<[email protected]>
    530 5.7.0 Must issue a STARTTLS command first
    com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first
         at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1275)
         at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:895)
         at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:524)
         at javax.mail.Transport.send0(Transport.java:151)
         at javax.mail.Transport.send(Transport.java:80)
         at test.Send.send(Send.java:50)
         at test.Send.main(Send.java:68)
    QUIT
    com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first
         at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1275)
         at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:895)
         at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:524)
         at javax.mail.Transport.send0(Transport.java:151)
         at javax.mail.Transport.send(Transport.java:80)
         at test.Send.send(Send.java:50)
         at test.Send.main(Send.java:68)
    Can any body help me..??
    Thanks and Regards
    Jijo vincent

    Hi All,
    I am new to javax.mail.
    I have attached my code and also error here...
    can anyone help to resolve the error?
    Code:
    public class MailExample {
         public static void main(String args[]) {
              try {
              String host = "localhost"; //args[0];
              String from = "[email protected]"; //args[1];
    //          String to = "[email protected]";//args[2];
              String to = "[email protected]";//args[2];
              java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
              // Get system properties
              Properties props = System.getProperties();
              // Setup mail server
              props.put("mail.smtp.host", host);
              props.put("mail.smtp.starttls.enable","true");
              //props.put("mail.smtp.auth","true");
              // Get session
              Session session = Session.getDefaultInstance(props, null);
              session.setDebug(true);
              // Define message
              MimeMessage message = new MimeMessage(session);
              // Set the from address
              message.setFrom(new InternetAddress(from));
              // Set the to address
              message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
              // Set the subject
              message.setSubject("Hello JavaMail");
              // Set the content
              message.setText("Welcome to JavaMail");
              // Send message
              Transport.send(message);
              catch(AddressException ae){
                   ae.printStackTrace();
              }catch (MessagingException e)
    //               TODO Auto-generated catch block
                   e.printStackTrace();
    Error:
    DEBUG: setDebug: JavaMail version 1.3.3ea
    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 "localhost", port 25, isSSL false
    220 localhost
    DEBUG SMTP: connected to host "localhost", port: 25
    EHLO HDCHCTDAM33726
    250-localhost
    250 HELP
    DEBUG SMTP: Found extension "HELP", arg ""
    DEBUG SMTP: use8bit false
    MAIL FROM:<[email protected]>
    250 [email protected] Address Okay
    RCPT TO:<[email protected]>
    250 [email protected] Address Okay
    DEBUG SMTP: Verified Addresses
    DEBUG SMTP: [email protected]
    DATA
    354 Start mail input; end with <CRLF>.<CRLF>
    Message-ID: <10736847.01125315340863.JavaMail.sangeetham@HDCHCTDAM33726>
    From: [email protected]
    To: [email protected]
    Subject: Hello JavaMail
    MIME-Version: 1.0
    Content-Type: text/plain; charset=us-ascii
    Content-Transfer-Encoding: 7bit
    Welcome to JavaMail
    com.sun.mail.smtp.SMTPSendFailedException: 550 Invalid recipient: [email protected]
         at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1333)
         at com.sun.mail.smtp.SMTPTransport.finishData(SMTPTransport.java:1160)
         at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:538)
         at javax.mail.Transport.send0(Transport.java:151)
         at javax.mail.Transport.send(Transport.java:80)
         at org.worldbank.webmfr.util.MailExample.main(MailExample.java:55)550 Invalid recipient: [email protected]
    com.sun.mail.smtp.SMTPSendFailedException: 550 Invalid recipient: [email protected]
         at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1333)
         at com.sun.mail.smtp.SMTPTransport.finishData(SMTPTransport.java:1160)
         at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:538)
         at javax.mail.Transport.send0(Transport.java:151)
         at javax.mail.Transport.send(Transport.java:80)
         at org.worldbank.webmfr.util.MailExample.main(MailExample.java:55)
    QUIT

  • Error while sending mail from SAP system

    Hi all,
    I configured SAP connect  in ecc6.0 ehp7 while sending mail using tx sost i am error
    Message cannot be transferred to node SMTP due to connection error (final) , below is the icm log.
    ERROR => IcmPlAllocBuf: MpiGetOutbuf failed (rc = 14(MPI_ESTALE: outdated MPI handle)) [icxxplugin.c 1222]
    ERROR => SMTP SmtpClientClose: alloc failed, rc = -3 [smtp_plg.c   3738]
    ERROR => IcmBufFree(id=0/32): MpiFreeBuf failed (rc=14), MPI_ESTALE: outdated MPI handle [icxxplugin.c 165
    ERROR => IcmConnClose: PlugInStopConn failed (rc=701) [icxxconn.c   3433]
    can any one please help on this
    Thanks,
    Narendar.

    Hello Priyanka,
    Actually, I performed the following two steps in order to solve the issue:
    - In transaction SICF, the node for SAPConnect must be active. In our system, this node was in inactive state. Hence I activated it.
    - Then In transaction SCOT-> Settings menu--> default domain should be 'xyz.com' if the email addresses in your company are maintained with a suffix  xyz.com.
    But for me the problem didnt get solved here..
    The problem that i am facing now is that if in my user profile, I have the email address maintained, then i get an error saying 'Sender address rejected'. However, if i goto transaction SU01 and clear the email id, the mail is successfully sent to outer world.
    You can try the above mentioned two steps using SICF and SCOT. If the problem does not get solved then try clearing the mail id in ur user profile.
    Hope this helps. If you find an answer to the problem of the mail id getting cleared, then please let me know..
    Regards,
    Himanshu

  • Issues with their Chinese or Japanese characters while sending mail

    Hi All ,
    I am sending mail using FM SO_DOCUMENT_SEND_API1. I am facing problem with display of chinese and japanese character in mail attachment.
    For example , Data in ABAP table 延平路123弄1号10A is converted to ösï721_ 3S÷83L in excel sent via mail through abap.
    I am using ASCII conversion while filling internal table for attachment.  Since these are not ASCII character conversion is not helpful.
    Please help me for solving above problem.
    Thanks & Regards ,
    Jigar Thakkar.

    Hi Kang Ring,
    please convert the content of the attachement into the binary format and then add it as a mail attachment.
    LOOP AT i_data ASSIGNING <wa_data>.
    if s_output is INITIAL.
    CONCATENATE <wa_data> cl_abap_char_utilities=>cr_lf into s_output.
    else.
    CONCATENATE s_output <wa_data> INTO s_output SEPARATED BY cl_abap_char_utilities=>cr_lf.
    endif.
    ENDLOOP.
    CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
    EXPORTING
    text = s_output
    IMPORTING
    buffer = x_output.
    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
    buffer = x_output
    TABLES
    binary_tab = imail_att.
         OR
    please use ABAP-Object classes like CL_BCS , CL_document_BCS.....
    please findthe below sample code.
      cl_bcs_convert=>string_to_solix(
              EXPORTING
                iv_string   = s_output
                iv_codepage = '4103'          "suitable for MS Excel, leave empty
                iv_add_bom  = 'X'               "for other doc types
              IMPORTING
                et_solix  = s_output_binary  "(of type solix_tab)
                ev_size   = size ).
    attachment->add_attachment(                       "attachment of type ref to cl_document_bcs
              i_attachment_type    = 'xls'                     
              i_attachment_subject = l_subject    
              i_attachment_size    = size
              i_att_content_hex    = s_output_binary ).
    you need to write the code for adding the receipents, subject and adding this "attachment " as an attachment to the mail.
    Hope this will helps to you....,
    thanks,
    Rahim.

  • Hi, I am new to Mac and i managed to install and configure all the services. Now my issue is when i sending mail using the local server to internal, mail are not receiving. Mail queue showing Connection refused error. Please help me

    I am new to Mac and i managed to install and configure all the services. Now my issue is when i sending mail using the local server to internal, mails are not receiving. Mail queue showing Connection refused error. Please help me
    Thanks
    GIRI

    Try this -> http://support.apple.com/kb/TA38632?viewlocale=en_US

  • Error While sending mail

    Working with 9.1.0.1
    I have created a task which will send Mail to user when password is changed.
    so in Notification Tab i Have clicked user check box and attached a appropiate Email Defination,
    when task is triggered password is changed in OID but while sending mail i am getting below error.
    I checked in metalink its shows when Email Server IT Res Name should be same as that configured in System property ,i checked both are same.
    1 Dec 2011 18:06:54,735,[XELLERATE.REQUESTS],Class/Method: tcEmailNotificationUtil/sendEmail encounter some problems: {1}
    lang.NullPointerException
    at java.util.Hashtable.put(Hashtable.java:394)
    at com.thortech.xl.dataobj.util.tcEmailNotificationUtil.sendEmail(Unknown Source)
    at com.thortech.xl.dataobj.tcScheduleItem.checkForEmailNotification(Unknown Source)
    at com.thortech.xl.dataobj.tcScheduleItem.eventPostUpdate(Unknown Source)
    at com.thortech.xl.dataobj.tcDataObj.update(Unknown Source)
    at com.thortech.xl.dataobj.tcDataObj.save(Unknown Source)
    at com.thortech.xl.adapterfactory.events.tcAdpEvent.updateSchItem(Unknown Source)
    at com.thortech.xl.adapterfactory.events.tcAdpEvent.finalizeProcessAdapter(Unknown Source)
    at com.thortech.xl.adapterfactory.events.tcAdpEvent.finalizeAdapter(Unknown Source)
    at com.thortech.xl.adapterGlue.ScheduleItemEvents.adpOIDMODIFYUSER.implementation(adpOIDMODIFYUSER.java:81)
    at com.thortech.xl.client.events.tcBaseEvent.run(Unknown Source)
    at com.thortech.xl.dataobj.tcDataObj.runEvent(Unknown Source)
    at com.thortech.xl.dataobj.tcScheduleItem.runMilestoneEvent(Unknown Source)
    at com.thortech.xl.dataobj.tcScheduleItem.eventPostInsert(Unknown Source)
    at com.thortech.xl.dataobj.tcDataObj.insert(Unknown Source)
    at com.thortech.xl.dataobj.tcDataObj.save(Unknown Source)
    at com.thortech.xl.client.events.tcTriggerUserProcesses.insertMileStones(Unknown Source)
    at com.thortech.xl.client.events.tcTriggerUserProcesses.trigger(Unknown Source)
    at com.thortech.xl.client.events.tcUSRTriggerUserProcesses.implementation(Unknown Source)
    at com.thortech.xl.client.events.tcBaseEvent.run(Unknown Source)
    at com.thortech.xl.dataobj.tcDataObj.runEvent(Unknown Source)
    at com.thortech.xl.dataobj.tcDataObj.eventPostUpdate(Unknown Source)
    at com.thortech.xl.dataobj.tcUSR.eventPostUpdate(Unknown Source)
    at com.thortech.xl.dataobj.tcDataObj.update(Unknown Source)
    at com.thortech.xl.dataobj.tcDataObj.save(Unknown Source)
    at com.thortech.xl.dataobj.tcTableDataObj.save(Unknown Source)
    at com.thortech.xl.ejb.beansimpl.tcUserOperationsBean.updateUserData(Unknown Source)
    at com.thortech.xl.ejb.beansimpl.tcUserOperationsBean.updateUser(Unknown Source)
    at com.thortech.xl.ejb.beans.tcUserOperationsSession.updateUser(Unknown Source)
    at com.thortech.xl.ejb.beans.tcUserOperations_voj9p2_EOImpl.updateUser(tcUserOperations_voj9p2_EOImpl.java:1763)
    at Thor.API.Operations.tcUserOperationsClient.updateUser(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor485.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)

    Create a task "Send Email" which will be called on SUCCESS of Change Password Task
    Attach tcComplete in INTEGRATION tab And send Email from "Send Email" using Notification Tab
    It seems that issue is with Change Password Task
    Or Use APIs
    Re: Send Mail via java code but using Mail Definitions

  • Issue with sending mail through java stored procedure in Oracle

    Hello
    I am using Oracle 9i DB. I created a java stored procedure to send mail using the code given below. The java class works fine standalone. When its run from Java, mail is sent as desired. But when the java stored procedure is called from pl/sql "Must issue a STARTTLS command first" error is thrown. Please let me know if am missing something. Tried the same code in 11.2.0.2 DB and got the same error
    Error:
    javax.mail.MessagingException: 530 5.7.0 Must issue a STARTTLS command first. va6sm31201010igc.6
    Code for creating java stored procedure: (T1 is the table created for debugging)
    ==================================================
    create or replace and compile java source named "MailUtil1" AS
    import java.util.Enumeration;
    import java.util.Properties;
    import javax.mail.Message;
    import javax.mail.Session;
    import javax.mail.Transport;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeMessage;
    public class MailUtil1 {
    public static void sendMailwithSTARTTLS(String host, //smtp.projectp.com
    String from, //sender mail id
    String fromPwd,//sender mail pwd
    String port,//587
    String to,//recepient email ids
    String cc,
    String subject,
    String messageBody) {
    try{
    Properties props = System.getProperties();
    props.put("mail.smtp.starttls.enable", "True"); // added this line
    props.put("mail.smtp.host", host);
    props.put("mail.smtp.user", from);
    props.put("mail.smtp.password", fromPwd);
    props.put("mail.smtp.port", port);
    props.put("mail.smtp.auth", "true");
    #sql { insert into t1 (c1) values ('1'||:host)};
    Session session = Session.getDefaultInstance(props, null);
    MimeMessage message = new MimeMessage(session);
    message.setFrom(new InternetAddress(from));
    #sql { insert into t1 (c1) values ('2')};
    InternetAddress[] toAddress = new InternetAddress[1];
    // To get the array of addresses
    for( int i=0; i < toAddress.length; i++ ) { // changed from a while loop
    toAddress[i] = new InternetAddress(to);
    //System.out.println(Message.RecipientType.TO);
    for( int i=0; i < toAddress.length; i++) { // changed from a while loop
    message.addRecipient(Message.RecipientType.TO, toAddress);
    if (cc!=null) {
    InternetAddress [] ccAddress = new InternetAddress[1];
    for(int j=0;j<ccAddress.length;j++){
    ccAddress[j] = new InternetAddress(cc);
    for (int j=0;j<ccAddress.length;j++){
    message.addRecipient(Message.RecipientType.CC, ccAddress[j]);
    message.setSubject(subject);
    message.setText(messageBody);
    message.saveChanges();
    #sql { insert into t1 (c1) values ('3')};
    Enumeration en = message.getAllHeaderLines();
    String token;
    while(en.hasMoreElements()){
    token ="E:"+en.nextElement().toString();
    #sql { insert into t1 (c1) values (:token)};
    token ="ConTyp:"+message.getContentType();
    #sql { insert into t1 (c1) values (:token)};
    token = "Encod:"+message.getEncoding();
    #sql { insert into t1 (c1) values (:token)};
    token = "Con:"+message.getContent();
    #sql { insert into t1 (c1) values (:token)};
    Transport transport = session.getTransport("smtp");
    #sql { insert into t1 (c1) values ('3.1')};
    transport.connect(host, from, fromPwd);
    #sql { insert into t1 (c1) values ('3.2')};
    transport.sendMessage(message, message.getAllRecipients());
    #sql { insert into t1 (c1) values ('3.3')};
    transport.close();
    #sql { insert into t1 (c1) values ('4')};
    catch(Exception e){
    e.printStackTrace();
    String ex= e.toString();
    try{
    #sql { insert into t1 (c1) values (:ex)};
    catch(Exception e1)
    Edited by: user12050615 on Jan 16, 2012 12:18 AM

    Hello,
    Thanks for the reply. Actually I have seen that post before creating this thread. I thought that I could make use of java mail to work around this problem. I created a java class that succesfully sends mail to SSL host. I tried to call this java class from pl-sql through java stored procedure. That did not work
    So, is this not supported in Oracle ? Please note that I have tested this in both 9i and 11g , in both the versions I got the error. You can refer to the code in the above post.
    Thanks
    Srikanth
    Edited by: user12050615 on Jan 16, 2012 12:17 AM

  • Error in sending mail using ssl server

    Hi All
    Please help in resolving the below issue i am getting the following error while sending mail. I am using the IMAP server and it is ssl configured.
    DEBUG: setDebug: JavaMail version 1.4ea
    DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc]
    DEBUG SMTP: useEhlo true, useAuth false
    DEBUG SMTP: trying to connect to host "mail.test.com", port 465, isSSL true
    DEBUG SMTP: exception reading response: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: subject/issuer name chaining check failed
    javax.mail.MessagingException: Exception reading response;
      nested exception is:
         javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: subject/issuer name chaining check failed
         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 com.test.test.JavaMailApp2.main(JavaMailApp2.java:59)
    Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: subject/issuer name chaining check failed
         at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Unknown Source)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(Unknown Source)
         at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Unknown Source)
         at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Unknown Source)
         at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(Unknown Source)
         at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(Unknown Source)
         at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Unknown Source)
         at com.sun.net.ssl.internal.ssl.Handshaker.process_record(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:97)
         at java.io.BufferedInputStream.fill(Unknown Source)
         at java.io.BufferedInputStream.read(Unknown Source)
         at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:75)
         at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1440)
         ... 4 more
    Caused by: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: subject/issuer name chaining check failed
         at sun.security.validator.PKIXValidator.doValidate(Unknown Source)
         at sun.security.validator.PKIXValidator.doValidate(Unknown Source)
         at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)
         at sun.security.validator.Validator.validate(Unknown Source)
         at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.validate(Unknown Source)
         at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
         at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
         ... 17 more
    Caused by: java.security.cert.CertPathValidatorException: subject/issuer name chaining check failed
         at sun.security.provider.certpath.PKIXMasterCertPathValidator.validate(Unknown Source)
         at sun.security.provider.certpath.PKIXCertPathValidator.doValidate(Unknown Source)
         at sun.security.provider.certpath.PKIXCertPathValidator.engineValidate(Unknown Source)
         at java.security.cert.CertPathValidator.validate(Unknown Source)
         ... 24 moreBelow is the source code of the program.
    package com.test.test;
    import java.security.Security;
    import java.util.Properties;
    import javax.mail.Authenticator;
    import javax.mail.Message;
    import javax.mail.MessagingException;
    import javax.mail.NoSuchProviderException;
    import javax.mail.PasswordAuthentication;
    import javax.mail.Session;
    import javax.mail.Transport;
    import javax.mail.internet.AddressException;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeMessage;
    public class JavaMailApp {
         public static void main( String[] args )
              String d_email = "[email protected]";
              String d_uname = "ots.support";
              String d_password = "password";
              String d_host = "mail.test.com";
              String d_port  = "465"; //465,587
              String m_to = "[email protected]";
              String m_subject = "Testing";
              String m_text = "Hey, this is the testing email.";
              Properties props = new Properties();
              props.put("mail.smtp.user", d_email);
              props.put("mail.smtp.host", d_host);
              props.put("mail.smtp.port", d_port);
              props.put("mail.smtp.starttls.enable","true");
              props.put("mail.smtp.debug", "true");
              props.put("mail.smtp.auth", "true");
              props.put("mail.smtp.socketFactory.port", d_port);
              props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
              props.put("mail.smtp.socketFactory.fallback", "false");
              SMTPAuthenticator auth = new SMTPAuthenticator();
              Session session = Session.getInstance(props, auth);
              session.setDebug(true);
              MimeMessage msg = new MimeMessage(session);
              try {
                   msg.setText(m_text);
                   msg.setSubject(m_subject);
                   msg.setFrom(new InternetAddress(d_email));
                   msg.addRecipient(Message.RecipientType.TO, new InternetAddress(m_to));
                   Transport transport = session.getTransport("smtps");
                   transport.connect(d_host, 465, d_uname, d_password);
                   transport.sendMessage(msg, msg.getAllRecipients());
                   transport.close();
              } catch (MessagingException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
    public class SMTPAuthenticator extends Authenticator{
         public PasswordAuthentication getPasswordAuthentication()
            return new PasswordAuthentication("[email protected]", "password");
    }I have also added the certificate to my keystore using the following command and still i am facing this issue.
    keytool -import -trustcacerts -alias root -file mail_test_com.crt -keystore keystore.jks
    Add to fierof2's Reputation

    this is where i created the keystore.jks file
    I navigated to the location C:\Program Files\Java\jdk1.6.0_13\bin in command prompt and typed the following command to create the keystore
    keytool -import -trustcacerts -alias root -file mail_test_com.crt -keystore keystore.jksI was asked to set the password for keystore and then i was asked the question "Trust this certificate? [no]:" for which i gave yes.
    If this is not the right place to create the keystore.jks can you please tell me what is correct location to create the keystore file.

Maybe you are looking for

  • Inbound Delivery creation in ECC6.0 through IDoc (DELVRY03.DESADV)

    Inbound Delivery creation in ECC6.0 through IDoc (DELVRY03.DESADV) From SCM ICH system Supplier creates ASN on the WEBUI & sends it ECC 6.0 using XI. This is Proxy (DespatchedDeliveryNotification) to IDOC (DELVRY03.DESAV) scenario But at the receiver

  • Mutt and msmtp - I just can't get mutt to send

    Hello all, I have been battling with this for some time, I hope you can help. I have been running arch for several years now and thought I might start using mutt.  I have installed the version from the AUR with the side bar patch (version 1.5.21) and

  • Does iPhone 4S (AT&T) fit in iPhone 4 case (AT&T)?

    I just got a iPhone 4S (AT&T), and I wanted to use the bumper I'm currently using for my old iPhone 4 (AT&T). However, it doesn't fit exactly. The hole for the mute switch doesn't match with the iPhone 4S'. I read somewhere on the Internet saying Ver

  • Help needed in interpreting panic log from kernel panic error

    My G4 iBook has started giving me kernel panic errors, often immediately after starting up. I haven't installed any new software or RAM recently. I've done a clean system install (completely clean - not an archive and install) then downloaded the com

  • Pdf opened in Acrobat different in Illustrator

    I received a pdf that opens in Acrobat and Photoshop one way, (as a 3.5x2 business card) then opens as an 8.5 x 11, 10 up set of bus cards in Illustrator. How is this happening? (I do get font substitute message, but what would that have to do with s