JavaMail API didnt work in UNIX environment

I facing a problem whereby my JavaMail class, as below:
public class MailExample {
public static void main (String args[]) throws Exception {
String from = " "; // email address of the sender
String to = " "; // email address of the receipient
String host = " "; // mail server id
String subject = " "; // subject for the mail
String content = " "; //content of the mail
String error = null;
     try{
     // Get system properties
          Properties props = System.getProperties();
     // Set the transport protocol format
     props.put("mail.transport.protocol", "SMTP");
     // Setup mail server
     props.put("mail.smtp.host", host);
     // Get session     
     Session session = Session.getDefaultInstance(props, null);
     // 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(subject);
     // Set the content
     message.setText(content);
     // Send message
     Transport.send(message);
     }catch (Exception e)
          error = e.getMessage();
     System.out.println("\n" + error);
This class works in Window based Exchange Server but not working in UNIX Exchange Server. Can anyone help me on this problem?
Thanks.

i'd found a solution for this problem.
this is the code i use:
try{
                    PrintStream out1;
                    SmtpClient send = new SmtpClient("smtp........com"); // create a mail client
                    send.from(emailVal); // email address of the sender
                    send.to(" "); // email address of the receiver
                    out1 = send.startMessage();
                    //Format of the email
                    out1.println("From: [email protected]");
                    out1.println("To: [email protected]");
                    out1.println("Subject: " + subject);
                    out1.println(content);
                    out1.flush();
                    out1.close();
                    send.closeServer();
               catch (Exception e) {
                    errorMsg = e.getMessage();
I'd used smtpClient to replace the JavaMail it really works in UNIX but it will show error : connection reset if you run it in Window environment.

Similar Messages

  • JQuery.js not working in UNIX environment

    Hi All,
    My development environment is Linux with Apache and we are using Coldfusion 9.
    We have developed some part of our code using jQuery.
    This is perfectly working in our DEV environment.
    We shipped the same code to the Production Environment. Which is Coldfusion 5 and Unix Environment with Apache Server.
    The problem is the parameter passing to jQuery is always null.
    Is jQuery will not work in Coldfusion 5?
    Your help is needed.
    Thanks in advance!

    1. CF versions 9 and 5 and radically different.  I wouldn't expect code written for CF9 to run on CF5.
    2. CF runs on the server, jQuery runs in the brower, the version of CF on your server shouldn't be relavent.  You should look for the problem in the HTML, Javascript, CSS, etc. in the browser.
    3. We cannot help diagnose your problem without seeing the code that is causing the problem and any error messages you receive.
    4. If this is a issue with jQuery on the browser you might consider posting a question to a jQuery specific forum.

  • Will JCO work in Unix Environment and in Webshere 3.5

    I need to know whether SAPJCO.jar will work fine in unix environment and also whether is it compactible with websphere version 3.4.

    Hi Nikki,
    The answer for your question is <b>YES</b>. Unix supports java and Websphere. I think you are aware of of running complex J2EE applications on websphere. If you are able to run java based applications on your server and do not worry you can run sapjco.jar without any problem. Recently we had an integration project [ SAP R/3 and Lotus Domino Server]. It worked out perfectly.
    Read this will let you know more,
    http://www-128.ibm.com/developerworks/websphere/zones/portal/catalog/doc/appportletbuilder/ApplicationPortletBuilder_v410_wsdd.html
    Hope this will solve your problem.
    Thanks
    Kathirvel

  • How does the idle() for IMAP works in JavaMail API ?

    Hi,
    I would like to know how the idle() works in the JavaMail API.
    Please check the below code:
    f.addMessageCountListener(new MessageCountAdapter(){
                    @Override
              public void messagesAdded(MessageCountEvent ev) {
                  Message[] msgs = ev.getMessages();
                  System.out.println("Got " + msgs.length + " new messages for:" +  userID);             
                        try
                            newMailCount = newMailCount + msgs.length;
                            System.out.println("Got total:" + newMailCount + " new messages for:"+ userID);             
                        } catch (Exception e) {
                       e.printStackTrace();
    for (;;) {
                  if ( f instanceof IMAPFolder) {
                        IMAPFolder impf = (IMAPFolder)f;
                        impf.idle();
                        System.out.println("IDLE done");
                  } When i run the above code, the idle command keeps on listening to the new mails arrive. When will the idle process stop?
    O/P :
    Got 1 new messages for:test1
    Got total:1 new messages for:test1
    Got 1 new messages for:test1
    Got total:2 new messages for:test1
    Got 1 new messages for:test1
    Got total:3 new messages for:test1
    Got 1 new messages for:test1
    As you can see, the last line: "IDLE done" is not at all printed.
    How can i stop the idle process ?
    Thanks in advance,
    grace.

    For the above code, after some time the below exception is thrown:
    javax.mail.FolderClosedException: * BYE JavaMail Exception: java.net.SocketException: Connection reset
    at com.sun.mail.imap.IMAPFolder.throwClosedException(IMAPFolder.java:2464)
    at com.sun.mail.imap.IMAPFolder.idle(IMAPFolder.java:2256)
    Is this the normal behaviour ? Or is there anything else that i should take care of ?
    Thanks & Regards,
    grace

  • Error using wldeploy in unix environment

    I am trying to use wldeploy ant task to deploy and undeploy applications from my server in a unix environment, and keep getting errors there, and not locally on a XP development workstation. Below are my buildfile and the error that I am getting. Anyone have any ideas as to what may be wrong?
    build.xml
    <target name="undeploy" description="Undeploys app">
    <wldeploy user="${user}" password="${password}"
    adminurl="${adminurl}" remote="true"
         action="stop" name="${appname}" debug="true"
    verbose="true"/>
    </target>
    And here is the error:
    [wldeploy] weblogic.Deployer -debug -remote -verbose -noexit -name ${appname} -adminurl iiop://${host}:${port} -user ${user} -password ${password} -stop
    [wldeploy] weblogic.Deployer invoked with options: -debug -remote -verbose -noexit -name broker-co
    ntact.ear -adminurl iiop://${host}:${port} -user ${user} -stop
    [wldeploy] [WebLogicDeploymentManagerImpl.<init>():103] : Constructing DeploymentManager for J2EE v
    ersion V1_4 deployments
    [wldeploy] [WebLogicDeploymentManagerImpl.getNewConnection():146] : Connecting to admin server at a
    lice.healthpartners.com:8001, as user system
    [wldeploy] [ServerConnectionImpl.getEnvironment():288] : setting environment
    [wldeploy] [Debug.say():43] : getting context using iiop://alice.healthpartners.com:8001
    [wldeploy] [Debug.say():43] : Connecting to MBeanServer at service:jmx:iiop://${host}:${port}/jndi/weblogic.management.mbeanservers.domainruntime
    [wldeploy] java.io.IOException
    [wldeploy] at weblogic.management.remote.common.ClientProviderBase.makeConnection(ClientProvide
    rBase.java:135)
    [wldeploy] at weblogic.management.remote.common.ClientProviderBase.newJMXConnector(ClientProvid
    erBase.java:79)
    [wldeploy] at javax.management.remote.JMXConnectorFactory.newJMXConnector(JMXConnectorFactory.j
    ava:341)
    [wldeploy] at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:262)
    [wldeploy] at weblogic.deploy.api.spi.deploy.internal.ServerConnectionImpl.getMBeanServer(Serve
    rConnectionImpl.java:240)
    [wldeploy] at weblogic.deploy.api.spi.deploy.internal.ServerConnectionImpl.getMBeanServerForTyp
    e(ServerConnectionImpl.java:191)
    [wldeploy] at weblogic.deploy.api.spi.deploy.internal.ServerConnectionImpl.init(ServerConnectio
    nImpl.java:147)
    [wldeploy] at weblogic.deploy.api.spi.deploy.WebLogicDeploymentManagerImpl.getNewConnection(Web
    LogicDeploymentManagerImpl.java:148)
    [wldeploy] at weblogic.deploy.api.spi.deploy.WebLogicDeploymentManagerImpl.<init>(WebLogicDeplo
    ymentManagerImpl.java:118)
    [wldeploy] at weblogic.deploy.api.spi.factories.internal.DeploymentFactoryImpl.getDeploymentMan
    ager(DeploymentFactoryImpl.java:84)
    [wldeploy] at weblogic.deploy.api.tools.SessionHelper.getDeploymentManager(SessionHelper.java:4
    32)
    [wldeploy] at weblogic.deploy.api.tools.deployer.Jsr88Operation.connect(Jsr88Operation.java:302
    [wldeploy] at weblogic.deploy.api.tools.deployer.Deployer.perform(Deployer.java:137)
    [wldeploy] at weblogic.deploy.api.tools.deployer.Deployer.runBody(Deployer.java:88)
    [wldeploy] at weblogic.utils.compiler.Tool.run(Tool.java:158)
    [wldeploy] at weblogic.utils.compiler.Tool.run(Tool.java:115)
    [wldeploy] at weblogic.Deployer.run(Deployer.java:70)
    [wldeploy] at weblogic.Deployer.mainWithExceptions(Deployer.java:62)
    [wldeploy] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [wldeploy] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
    [wldeploy] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java
    :43)
    [wldeploy] at java.lang.reflect.Method.invoke(Method.java:615)
    [wldeploy] at weblogic.ant.taskdefs.management.WLDeploy.invokeMain(WLDeploy.java:419)
    [wldeploy] at weblogic.ant.taskdefs.management.WLDeploy.execute(WLDeploy.java:349)
    [wldeploy] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
    [wldeploy] at org.apache.tools.ant.Task.perform(Task.java:364)
    [wldeploy] at org.apache.tools.ant.Target.execute(Target.java:341)
    [wldeploy] at org.apache.tools.ant.Target.performTasks(Target.java:369)
    [wldeploy] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
    [wldeploy] at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
    [wldeploy] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:4
    0)
    [wldeploy] at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
    [wldeploy] at org.apache.tools.ant.Main.runBuild(Main.java:668)
    [wldeploy] at org.apache.tools.ant.Main.startAnt(Main.java:187)
    [wldeploy] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
    [wldeploy] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
    [wldeploy] Caused by: javax.naming.CommunicationException [Root exception is java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is:
    [wldeploy] java.io.EOFException]
    [wldeploy] at weblogic.jrmp.Context.lookup(Context.java:189)
    [wldeploy] at weblogic.jrmp.Context.lookup(Context.java:195)
    [wldeploy] at javax.naming.InitialContext.lookup(InitialContext.java:363)
    [wldeploy] at weblogic.management.remote.common.ClientProviderBase.makeConnection(ClientProvide
    rBase.java:126)
    [wldeploy] ... 35 more
    [wldeploy] Caused by: java.rmi.ConnectIOException: error during JRMP connection establishment; nest
    ed exception is:
    [wldeploy] java.io.EOFException
    [wldeploy] at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:293)
    [wldeploy] at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:190)
    [wldeploy] at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:321)
    [wldeploy] at weblogic.jrmp.BaseRemoteRef.invoke(BaseRemoteRef.java:221)
    [wldeploy] at weblogic.jrmp.RegistryImpl_Stub.lookup(Unknown Source)
    [wldeploy] at weblogic.jrmp.Context.lookup(Context.java:185)
    [wldeploy] ... 38 more
    [wldeploy] Caused by: java.io.EOFException
    [wldeploy] at java.io.DataInputStream.readByte(DataInputStream.java:269)
    [wldeploy] at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:234)
    [wldeploy] ... 43 more
    [wldeploy] [Debug.say():43] : Closing DM connection
    [wldeploy] [Debug.say():43] : Unregistered all listeners
    [wldeploy] weblogic.deploy.api.tools.deployer.DeployerException: Unable to connect to 'iiop://${host}:${port}': null. Ensure the url represents a running admin server and that the crede
    ntials are correct. If using http protocol, tunneling must be enabled on the admin server.
    Thanks.
    Scott

    Hi Richard,
    I had the same issue using Eclipse. I just tried to run the
    ant script outside of Eclipse and it worked fine.
    This is an Eclipse-Ant Class Loader issue.
    In order to make it work in Eclipse, You have to :
    1. Open the External Tool Run Configuration.
    2. Select your Ant script.
    3. Select JRE Tab.
    4. In Runtime JRE section, choose Seperate JRE.
    Hope this helps !
    Eric

  • Error Registering 11g SOA Composite in Unix environment

    Hi All,
    We are trying to register a SOA Approval Composite with OIM 11.1.1.3 in the Unix environement . The SOA Process is getting successfully deployed , but when we are registering it , its throwing error as : "The task definition at default/ProvisioningApprovalFlow!1.0*soa_***************/ApprovalTask could not be read".
    However, same workflow is getting successfully registered and executed in Windows environment. Any suggestion what could go wrong here. I am providing here the error details . Any help is heartly appreciated.
    Exception in thread "main" oracle.iam.platform.workflowservice.exception.IAMWorkflowException: Tasklist mapping failed for workflowdefinition:
    default/ProvisioningApprovalFlow!1.0 due to Invalid task definition.Ni
    [java] The task definition at default/ProvisioningApprovalFlow!1.0*soa_7abcd53a-69ca-4c93-909b-88e59015e026/ApprovalTask could not be read. The task definition is
    associated with workflow default/ProvisioningApprovalFlow!1.0*soa_7abcd53a-69ca-4c93-909b-88e59015e026/ApprovalTask.
    [java] Make sure that the task definition is available at the specified URL and that it is a valid XML document.
    [java]
    [java] at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:234)
    [java] at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:348)
    [java] at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:259)
    [java] at
    oracle.iam.platformservice.api.WorkflowRegistrationServiceEJB_f4otyb_WorkflowRegistrationServiceRemoteImpl_1033_WLStub.registerWorkFlowDefinitionx(Unknown
    Source)
    [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [java] at java.lang.reflect.Method.invoke(Method.java:597)
    [java] at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:84)
    [java] at $Proxy2.registerWorkFlowDefinitionx(Unknown Source)
    [java] at oracle.iam.platformservice.api.WorkflowRegistrationServiceDelegate.registerWorkFlowDefinition(Unknown Source)
    [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [java] at java.lang.reflect.Method.invoke(Method.java:597)
    [java] at Thor.API.Base.SecurityInvocationHandler$1.run(SecurityInvocationHandler.java:68)
    [java] at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    [java] at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
    [java] at weblogic.security.Security.runAs(Security.java:41)
    [java] at Thor.API.Security.LoginHandler.weblogicLoginSession.runAs(weblogicLoginSession.java:52)
    [java] at Thor.API.Base.SecurityInvocationHandler.invoke(SecurityInvocationHandler.java:79)
    [java] at $Proxy3.registerWorkFlowDefinition(Unknown Source)
    [java] at oracle.iam.platformservice.workflowregclient.WorkflowRegistration.main(WorkflowRegistration.java:42)
    [java] Caused by: oracle.iam.platform.workflowservice.exception.IAMWorkflowException: Tasklist mapping failed for workflowdefinition:
    default/ProvisioningApprovalFlow!1.0 due to Invalid task definition.
    [java] The task definition at default/ProvisioningApprovalFlow!1.0*soa_7abcd53a-69ca-4c93-909b-88e59015e026/ApprovalTask could not be read. The task definition is
    associated with workflow default/ProvisioningApprovalFlow!1.0*soa_7abcd53a-69ca-4c93-909b-88e59015e026/ApprovalTask.
    [java] Make sure that the task definition is available at the specified URL and that it is a valid XML document.
    [java]
    [java] at oracle.iam.platform.workflowservice.impl.WorkflowRepositoryImpl.mapWorkflow(WorkflowRepositoryImpl.java:132)
    [java] at oracle.iam.platform.workflowservice.impl.WorkflowRepositoryImpl.registerWorkFlowDefinition(WorkflowRepositoryImpl.java:113)
    [java] at oracle.iam.platform.workflowservice.impl.WorkflowServiceImpl.registerWorkFlowDefinition(WorkflowServiceImpl.java:231)
    [java] at oracle.iam.platformservice.impl.WorkflowRegistrationServiceImpl.registerWorkFlowDefinition(WorkflowRegistrationServiceImpl.java:38)
    [java] at oracle.iam.platformservice.api.WorkflowRegistrationServiceEJB.registerWorkFlowDefinitionx(Unknown Source)
    [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [java] at java.lang.reflect.Method.invoke(Method.java:597)
    [java] at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
    [java] at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
    [java] at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
    [java] at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    [java] at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
    [java] at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    [java] at com.bea.core.repackaged.springframework.jee.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:37)
    [java] at weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:54)
    [java] at com.bea.core.repackaged.springframework.jee.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:50)
    [java] at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    [java] at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
    [java] at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    [java] at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    [java] at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
    [java] at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    [java] at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    [java] at $Proxy507.registerWorkFlowDefinitionx(Unknown Source)
    [java] at
    oracle.iam.platformservice.api.WorkflowRegistrationServiceEJB_f4otyb_WorkflowRegistrationServiceRemoteImpl.registerWorkFlowDefinitionx(WorkflowRegistrationServiceEJ
    B_f4otyb_WorkflowRegistrationServiceRemoteImpl.java:193)
    [java] at oracle.iam.platformservice.api.WorkflowRegistrationServiceEJB_f4otyb_WorkflowRegistrationServiceRemoteImpl_WLSkel.invoke(Unknown Source)
    [java] at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)
    [java] at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)
    [java] at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:477)
    [java] at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
    [java] at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
    [java] at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:473)
    [java] at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
    [java] at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
    [java] at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Thanks
    Swati Pandey

    Has any one faced similar issue ?

  • Javamail api and Microsoft Exchange

    Hi there,
    I wonder if there are different settings for the javamail (SMTP, Authentication) when the user is using Micorsoft Exchange.
    The problem is that my user doesn't know what is his SMTP (I usually ask them to go to MS Outlook to figure it out) but since he is using the exchange software how can I tell what is the SMTP?
    are there different setttings for the javamail api in this case?
    thanks
    peter

    P_Primrose and Others,
    I too am having the same issues. At my work i have administrative access to our MS Exchange server and have noticed that the server can be set to use OR block access via SMTP, POP or IMAP. Also the type of connection can also be set, Encrypted connections or non-encrypted connections.
    Now i my instance I have noted that we have SMTP blocked, therefore no good and i have to swap to IMAP. Yuck. But my problem is that if my application is going to be developed to be used across all environments, will i run into the same problems when using other mail servers, such as Unix servers, etc.
    My question to the world is how can you test a connection to a mail server and find out what it's requirements are??? Is there a way to get the settings from the client's system settings (Regedit)??? If this can be done then it's just a matter of building a routine to mirror and set those variables for your JavaMail.

  • Problem Sending mails in a loop using JavaMail API

    Hello All,
    I am sending emails in a loop(one after the other) using JavaMail API,but the problem is, if the first two,three email addresses in the loop are Valid it sends the Email Properly, but if the Fourth or so is Invalid Address it throws an Exception....
    "javax.mail.SendFailedException: Sending failed;"
    nested exception is:
    javax.mail.SendFailedException: Invalid Addresses;
    nested exception is:
    javax.mail.SendFailedException: 450 <[email protected]>:Recipient address rejected: Domain not found......
    So if i want to send hundereds of emails and if one of the Emails inbetween is Invalid the process Stops at that point and i could not send the other emails in the Loop......
    How Could i Trap the exception thrown and handle it in such a way, so that the loops continues ..
    Is there something with the SMTP Server....?
    The code which i am using is as follows....
    <Code>...
    try {
    InitialContext ic = new InitialContext();
    Session session = (Session) ic.lookup(JNDINames.MAIL_SESSION);
    if (Debug.debuggingOn)
    session.setDebug(true);
    // construct the message
    MimeMessage msg = new MimeMessage(session);
    msg.setFrom(new InternetAddress(eMess.getEmailSender()));
    String to = "";
    msg.setRecipients(Message.RecipientType.TO,
    InternetAddress.parse(to, false));
    msg.setRecipients(Message.RecipientType.BCC,
    InternetAddress.parse(eMess.getEmailReceiver(), false));
    msg.setSubject(eMess.getSubject());
    msg.setContent(eMess.getHtmlContents(),"text/plain");
    msg.saveChanges();                
    Transport.send(msg);
    } catch (Exception e) {
    Debug.print("createAndSendMail exception : " + e);
    throw new MailerAppException("Failure while sending mail");
    </Code>....
    Please give me any suggestions regarding it....and guide me accordingly..
    Thanks a million in advance...
    Regards
    Sam

    How about something like the code attached here. Be aware it is lifted and edited out of an app we have here so it may require changing to get it to work. If it don't work - don't come asking for help as this is only a rough example of one way of doing it. RTFM - that's how we worked it out!
    SH
    try {
    Transport.send(msg);
    // If we get to here then the mail went OK so update all the records in the email as sent
    System.out.println("Email sent OK");
    catch (MessagingException mex) {
    System.out.println("Message error");
    Exception ex = mex;
    do {
    if (ex instanceof SendFailedException) {
    if (ex.getMessage().startsWith("Sending failed")) {
    // Ignore this message as we want to know the real reason for failure
    // If we get an Invalid Address error or a Message partially delivered message process the message
    if (ex.getMessage().startsWith("Message partially delivered")
    || ex.getMessage().startsWith("Invalid Addresses")) {
    // This message is of interest as we need to process the actual individual addresses
    System.out.println(ex.getMessage().substring(0, ex.getMessage().indexOf(";")));
    // Now get the addresses from the SendFailedException
    SendFailedException sfex = (SendFailedException) ex;
    Address[] invalid = sfex.getInvalidAddresses();
    if (invalid != null) {
    System.out.println("Invalid Addresse(s) found -");
    if (invalid.length > 0) {
    for (int x = 0; x < invalid.length; x++) {
    System.out.println(invalid[x].toString().trim());
    Address[] validUnsent = sfex.getValidUnsentAddresses();
    if (validUnsent != null) {
    System.out.println("Valid Unsent Addresses found -");
    if (validUnsent.length > 0) {
    for (int x = 0; x < validUnsent.length; x++) {
    System.out.println(validUnsent[x].toString().trim());
    Address[] validSent = sfex.getValidSentAddresses();
    if (validSent != null) {
    System.out.println("Valid Sent Addresses found -");
    if (validSent.length > 0) {
    for (int x = 0; x < validSent.length; x++) {
    System.out.println(validSent[x].toString().trim());
    if (ex instanceof MessagingException)
    ex = ((MessagingException) ex).getNextException();
    else {
    // This is a general catch all and we should assume that no messages went and should stop
    System.out.println(ex.toString());
    throw ex;
    } while (ex != null);

  • How do I use a UNIX environment variable for the path of a file name

    We are running Forms 6i over the web. The forms server runs on a UNIX (HP-UX) machine.
    I want to read the contents of a file, which is simple enough, using the TEXT_IO package. However, I want to reference a UNIX environment variable that specifies the file path i.e
    PROCEDURE get_file IS
    in_file Text_IO.File_Type;
    linebuf VARCHAR2(1800);
    filename VARCHAR2(200);
    BEGIN
    filename:= '$LOG_DIR/RCAS181.log';
    in_file := Text_IO.Fopen(filename, 'r');
    .....other stuff
    Notice the filename string references my unix env variable '$LOG_DIR'. However, this doesnt work. If I put the full pathname it works fine.
    Any suggestions ?

    Have a look at TOOL_ENV.GETVAR()

  • Oracle in Unix environment...suggest way to start....

    Hi,
    Still i was a pl/sql programmer in windows platform. Now a sudden requirement to work pl/sql in unix environment. I very much new to unix. I dont know how to proceed. Please suggest start point where should i start...please help me
    thanks
    asp

    Thanks sharma,
    'You are welcome.'>
    U have been a good experienced person in this forums
    'I do not want to take this comment. In fact, I would not deserve it'
    'My experience is just 3 years in the S/W industry and full-time Oracle is '
    ' just less than that. But I deliberately wanted to participate actively in'
    ' this forum to gain knowledge from the other GURUs. But anyway thanks'
    ' your responses to a member in the forum.'
    whether i have to learn any unix
    specific os commands or no need of unix os command
    knowledge.
    'This depends on your work. If it purely for Oracle, then you do not have to'Cheers
    Sarma.

  • 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.

  • Exception not throwing to action class in Unix environment

    Hi
    We are using Weblogic Server 9.2.3.0.
    One of our EJB is not throwing exception to calling Action class in Unix environment. Its working fine in Windows.
    Somehow the EJB is swallowing the exception.
    any idea? I suspect it may be environmental issue?
    thank you

    Thanx for your reply.. I just found a solution and would like to share that with you. There are some default request parameters passed by the portal to the action class. "strutsAction" is one of them. If you print this parameters, you will see that it contains the complete url of your action. Now you can use String manipulation to extract the value of the parameters.
    I know its a crude solution. But it works fine.
    Best regards,
    Omer

  • Question about using JavaMail API to read the calendar folder...

    Hi,
    I've made an application that goes to the mail server, fetches all mails in the calendar folder and tells you the meetings you have in a particular day.
    I'm using JavaMail API for this. My problem is that the application is very slow because I'm forced to fetch (one by one!) the contents of every message.
    My question is: How can Outlook show so fast the mettings you have? Do they have a specific API that allows them to get the right info by only calling certain methods? Is there something similar in Java?
    Thaks for your help!
    Note: I use method:
    folder.fetch(allMessages, fetchProfile);howerver the fetchProfile class does not allow me to specfy that I want to dowload the contents of the message (you only can specify the content_info); specifying all headears does not help me either.

    Clarification:
    The VI you have posted will work as following:
    1) The task will read 2 analog inputs (ai0, ai3).
    2) The acquisition starts, oncece digital signal (trigger) is detected on PFI0
    3) The sampling rate will be as specified in "rate" control - it is continuous analog input acquisition, which means that after trigger is received (point 2), the board will start to generate hardware clock with frequency you specify as "rate"
    4) with each rising edge of that hardware clock, the measurement is taken, and stored into buffer of driver.
    5) DAQmx read will try to read "number of samples per channel" number of samples each time is called - and if there is not enough measurement stored in buffer (step 4), then DAQmx read will wait until DAQ card will measure reaquested number of samples (or timeout occurs before requested number of samples has been acquired)
    6) DAQmx read will be then called 1000 times - so totaly you will read 1000 * "number of samples per channel"  number of samples.
    You do not have to be worried about speed of the loop. In fact, if you need to read just 1000 samples, with 1kS/s, then you can remove for loop and you can change measurement mode from continuous to finite samples, and specify number of samples to read to be 1000. You will read them all properly. I recomend you to read User Manual for your DAQ device - lets say M Series User Manual.
    I hope it is clear now.
    regards,
    stefo

  • Problem accessing gmail with IMAP using JavaMail APIs

    Hi,
    I am trying to access my gmail account with JavaMail API. I am able to access it using pop3s but not with IMAP.
    I have used following details:
    protocol: imap
    host: imap.gmail.com
    port: -1 (also tried with 993) but no success.
    My basic code is
    url = new URLName(protocol, getHostname(), 993, mbox,
                              getUsername(), getPassword());
             Properties props = null;
             try {
              props = System.getProperties();
             } catch (SecurityException sex) {
              props = new Properties();
             session = Session.getInstance(props, null);
              session.setDebug(true);
            store = session.getStore(url);
            store.connect();
            folder = store.getFolder(url);
            folder.open(Folder.READ_WRITE);Any pointers?
    Thanks.

    Changed protocol from "imap" to "imaps"....and used port 993...and its working!!!!

  • Installation and deployment of operating system, applications and patches in Unix environment

    Is it possible to use Configuration Manager 2012 (or 2012 R2) to perform remote installation of operating system, applications and patching in a Unix environment?
    Balaji Kundalam

    ConfigMgr does not support Operating System Deployment for non-Windows OS flavors.
    You can use the ConfigMgr client on a Unix device to install applications and to instruct the device to install patches. Basically, the client will download files and run a script against them.  If there is a patch manager in your flavor of *nix, you
    can run a script to install the patches.
    See the supported operating systems here:
    http://technet.microsoft.com/en-us/library/gg682077.aspx#BKMK_SupConfigLnUClientReq
    I hope that helps,
    Nash
    Nash Pherson, Senior Systems Consultant
    Now Micro -
    My Blog Posts
    If you've found a bug or want the product worked differently,
    share your feedback.
    <-- If this post was helpful, please click "Vote as Helpful".

Maybe you are looking for