Javax.mail.MessagingException: Connection refused: connect on localhost

Hello,
I am using Tomcat5.0.28 for a javamail servlet program. I am giving the hostname as localhost. After entering the input details in my html file, i get the error- "javax.mail.MessagingException: Connection refused: connect; nested exception is: java.net.ConnectException: Connection refused: connect " .
can anybody help me regarding in solving error.
Thanks.

First, you're using a very old version of JavaMail.  Please upgrade.  Some of the properties you're setting aren't supported in that old version.
Second, you don't need the socket factory properties, get rid of them.
Finally, it looks like you're trying to connect on port 143 using SSL.  Port 143 is the non-SSL port.  That's probably not going to work.  Still, it looks like something is refusing to let you connect at all.  If you really can telnet from the same machine your program is running on to the same server machine on port 143, then you probably have some sort of firewall that's preventing your program from connecting.  Please post the entire debug output if it still fails after correcting the problems above.  (Move the setDebug call to before the getStore call.)

Similar Messages

  • Javax.mail.MessagingException: Could not connect to SMTP host:

    here is a part of my code
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;
    public class Mail {
    /** Creates a new instance of PostMail */
    public Mail() {
    public void postMail( String recipients[ ], String subject, String message , String from) throws MessagingException
    boolean debug = false;
    //Set the host smtp address
    Properties props = new Properties();
    props.put("mail.smtp.host", "smtp."_____".com");
    // create some properties and get the default Session
    Session session = Session.getDefaultInstance(props, null);
    session.setDebug(debug);
    // create a message
    Message msg = new MimeMessage(session);
    // set the from and to address
    InternetAddress addressFrom = new InternetAddress(from);
    msg.setFrom(addressFrom);
    InternetAddress[] addressTo = new InternetAddress[recipients.length];
    for (int i = 0; i < recipients.length; i++)
    addressTo[i] = new InternetAddress(recipients);
    msg.setRecipients(Message.RecipientType.TO, addressTo);
    // Optional : You can also set your custom headers in the Email if you Want
    msg.addHeader("MyHeaderName", "myHeaderValue");
    // Setting the Subject and Content Type
    msg.setSubject(subject);
    msg.setContent(message, "text/plain");
    Transport.send(msg);
    Here is the exception i rec'vd
    javax.mail.MessagingException: Could not connect to SMTP host: smtp.google.com, port: 25;
    nested exception is:
    java.net.ConnectException: Connection refused: connect
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1282)
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370)
    at javax.mail.Service.connect(Service.java:275)
    at javax.mail.Service.connect(Service.java:156)
    at javax.mail.Service.connect(Service.java:105)
    at javax.mail.Transport.send0(Transport.java:168)
    at javax.mail.Transport.send(Transport.java:98)
    at Mail.postMail(Mail.java:45)
    at ArchMain.<init>(ArchMain.java:30)
    at ArchMain$6.run(ArchMain.java:360)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
    Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:519)
    at java.net.Socket.connect(Socket.java:469)
    at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:232)
    at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1250)
    ... 17 more

    package MailDao;
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;
    import java.io.*;
    import java.text.*;
    import java.text.DateFormat.* ;
    import java.io.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.activation.*;
    import javax.mail.search.*;
    import java.util.Vector.*;
    import java.sql.*;
    public class SendMail {
    String SMTP_HOST_NAME = "smtp.techpepstechnology.com";//smtp.genuinepagesonline.com"; //techpepstechnology.com";
    String SMTP_AUTH_USER = "[email protected]"; //[email protected]"; //techpeps";
    String SMTP_AUTH_PWD = "demo"; //techpeps2007";
    public void postMail( String recipients[ ], String subject,
    String message , String from,String msgType) throws MessagingException {
    boolean debug = false;
    Properties props = System.getProperties();
    props.put("mail.transport.protocol", "smtp");
    props.put("mail.smtp.host", SMTP_HOST_NAME);
    props.put("mail.smtp.auth", "true");
    Authenticator auth = new SMTPAuthenticator();
    Session session = Session.getInstance(props, auth);
    session.setDebug(debug);
    // create a message
    MimeMessage msg = new MimeMessage(session);
    // MimeMessage mimemessage = new MimeMessage(simplemailuser.getSession());
    // set the from and to address
    InternetAddress addressFrom = new InternetAddress(from);
    msg.setFrom(addressFrom);
    InternetAddress[] addressTo = new InternetAddress[recipients.length];
    for (int i = 0; i < recipients.length; i++) {
    addressTo[i] = new InternetAddress(recipients);
    msg.setRecipients(Message.RecipientType.TO, addressTo);
    // Setting the Subject and Content Type
    msg.setSubject(subject);
    if(msgType.equalsIgnoreCase("")) {
    //mimemessage.setText(s4);
    msg.setContent(message, "text/plain");
    else {
    MimeBodyPart textBodyPart = new MimeBodyPart();
    textBodyPart.setText(message);
    MimeBodyPart fileBodyPart = new MimeBodyPart();
    FileDataSource fds = new FileDataSource(msgType);
    fileBodyPart.setDataHandler(new DataHandler(fds));
    fileBodyPart.setFileName(fds.getName());
    //step:5 create the multipart/container to hold the part
    Multipart container = new MimeMultipart();
    container.addBodyPart(textBodyPart);
    container.addBodyPart(fileBodyPart);
    //step:6 add the multipart to the actual message
    msg.setContent(container);
    try{
    Transport transport=session.getTransport("smtp");
    transport.connect();
    transport.send(msg);
    transport.close();
    }catch(Exception e) {
    e.printStackTrace();
    private class SMTPAuthenticator extends javax.mail.Authenticator {
    public PasswordAuthentication getPasswordAuthentication() {
    String username = SMTP_AUTH_USER;
    String password = SMTP_AUTH_PWD;
    return new PasswordAuthentication(username, password);
    public static void main(String arg[]) {
    SendMail sm = new SendMail();
    String[] s ={"[email protected]"};
    try{
    sm.postMail(s,"hello","This is testing of mail","[email protected]","");
    catch(Exception e)
    e.printStackTrace();
    //sm.sendMsg("demo", "demo");
    System.out.println("Mail Sent");
    i also got the follwing error this code work fine in jcreator but i used this in netbeans it throws a exception
    plz.....help
    javax.mail.MessagingException: Could not connect to SMTP host: smtp.techpepstechnology.com, port: 25;
    nested exception is:
    java.net.ConnectException: Connection refused: connect
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:867)
    Mail Sent
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:156)
    at javax.mail.Service.connect(Service.java:256)
    at javax.mail.Service.connect(Service.java:135)
    at javax.mail.Service.connect(Service.java:87)
    at com.sun.mail.smtp.SMTPTransport.connect(SMTPTransport.java:93)
    at MailDao.SendMail.postMail(SendMail.java:86)
    at MailDao.SendMail.main(SendMail.java:110)

  • Reading Inbox - javax.mail.MessagingException: Connect failed;

    I get an error message while trying to read emails by connecting to a company mailbox. The message is as follows:
    javax.mail.MessagingException: Connect failed;
    nested exception is:
         java.net.ConnectException: Connection refused: no further information
         boolean com.sun.mail.pop3.POP3Store.protocolConnect(java.lang.String, int, java.lang.String, java.lang.String)
         void javax.mail.Service.connect(java.lang.String, int, java.lang.String, java.lang.String)
         void javax.mail.Service.connect(java.lang.String, java.lang.String, java.lang.String)
         void GetMessageExample.main(java.lang.String[])
    The code is very simple and as follows:
    import java.io.*;
    import java.util.Properties;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    public class GetMessageExample {
    public static void main (String args[]) throws Exception {
    String host = "companyname.com";
    String username = "user";
    String password = "xxxx";
    try{
    // Create empty properties
    Properties props = new Properties();
    // Get session
    Session session = Session.getInstance(props, null);
    // Get the store
    Store store = session.getStore("pop3");
    store.connect(host, username, password);
    // Get folder
    Folder folder = store.getFolder("INBOX");
    folder.open(Folder.READ_ONLY);
    BufferedReader reader = new BufferedReader (
    new InputStreamReader(System.in));
    // Get directory
    Message message[] = folder.getMessages();
    for (int i=0, n=message.length; i<n; i++) {
    System.out.println(i + ": " + message.getFrom()[0]
    + "\t" + message[i].getSubject());
    // Close connection
    folder.close(false);
    store.close();
    } catch (Exception e) {
    e.printStackTrace();
    I have a two part question:
    1. At home I am using a dial-up connection it works when I change the settings to an email account as provided by the local ISP.
    I have tried it with both "pop3" and "imap" in
    Store store = session.getStore("pop3");
    for the company email but it does not work.
    Is this a problem with company security? Maybe firewall/proxy error? If so how do I get around it?
    2. Also, when I am in the office (LAN used to connect to Internet) I cannot even get a connection to the ISP account - similar problem or different?
    Any thoughts and help most appreciated.
    Thanks in advance,
    Mark

    It could be that the mail server is not accepting connections from the machine you are on. Have you tried using Outlook Express or the Netscape email client to connect to the server/account from the machine that is getting the failure?

  • Javax.mail.MessagingException: Not Connected

    Hi All,
    I am trying to read the message from pop.gmail.com using JavaMail API.I ma using POP3 protocol for it.
    But I got the following Exception
    javax.mail.MessagingException: Not Connected
    at com.sun.mail.pop3.POP3Store.checkConnected(POP3Store.java:279)
         at com.sun.mail.pop3.POP3Store.getFolder(POP3Store.java:261)
         at MailReceipt.connect(MailReceipt.java:97)
         at MailReceipt.mailRecieve(MailReceipt.java:62)
         at MailReceipt.main(MailReceipt.java:53)
    I got This Error at the line
    folder = store.getFolder("INBOX");
    in my program.
    Please Help me ion this regards.Thanks in Adnavce..
    Thanx & Regards
    Sandeep Verma

    Well, I've never used this API but it seems 100% clear what's wrong. And 5 seconds with Google has revealed that there's a method on that class which looks like it will address the issue.
    If you can't even read basic error messages, you should seriously question whether you should be programming.

  • Atg.service.email.EmailException: javax.mail.MessagingException:

    All, while sending email via web production application getting the following exception and it is intermittent as well, any quick pointers in cause/fix, please..
    ERROR [nucleusNamespace.atg.dynamo.service.EmailFormHandler] Failed to send meail message:Remember to set /atg/dynamo/service/SMTPEmail.emailHandlerHostName and /atg/dynamo/service/SMTPEmail.emailHandlerPort
    atg.service.email.EmailException: javax.mail.MessagingException: Exception reading response;
    nested exception is:
         java.net.SocketTimeoutException: Read timed out
         at atg.service.email.SMTPEmailSender.sendEmailMessage(SMTPEmailSender.java:907)
         at atg.service.email.SMTPEmailSender.sendEmailMessage(SMTPEmailSender.java:930)
         at atg.service.email.SMTPEmailSender.sendEmail(SMTPEmailSender.java:1009)
         at atg.service.email.SMTPEmailSender.sendEmailEvent(SMTPEmailSender.java:985)
         at atg.service.email.SMTPEmailSender.sendEmailMessage(SMTPEmailSender.java:522)
         at atg.service.email.EmailFormHandler.sendMail(EmailFormHandler.java:316)
         at atg.service.email.EmailFormHandler.handleSendEmail(EmailFormHandler.java:436)
         at sun.reflect.GeneratedMethodAccessor843.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:592)
         at atg.droplet.EventSender.sendEvent(EventSender.java:582)
         at atg.droplet.FormTag.doSendEvents(FormTag.java:791)
         at atg.droplet.FormTag.sendEvents(FormTag.java:640)
         at atg.droplet.DropletEventServlet.sendEvents(DropletEventServlet.java:523)
         at atg.droplet.DropletEventServlet.service(DropletEventServlet.java:550)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at atg.servlet.sessionsaver.SessionSaverServlet.service(SessionSaverServlet.java:2442)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at atg.commerce.order.CommerceCommandServlet.service(CommerceCommandServlet.java:128)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at atg.commerce.promotion.PromotionServlet.service(PromotionServlet.java:191)
         at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:116)
         at atg.userprofiling.AccessControlServlet.service(AccessControlServlet.java:602)

    Check the configuration of /atg/dynamo/service/SMTPEmail component and specify proper values for emailHandlerHostName, emailHandlerPort, username, password. By default emailHandlerHostName is configured to localhost and port is set to 25 which is default for SMTP. If you do not know these you can get these details from your mail administrator who has setup your mail-id. You would also need to specify the username and password if your administrator has not allowed for making anonymous connection to the mail server.

  • Mail doesn't send - javax.mail.MessagingException: 250

    Hello all,
    I'm new to JavaMail. I actually started with it last night. I've successfully sent a number of messages, but I randomly get a strange exception for no apparent reason.
    If I run the exact same code several times, it will produce this error about every 5 or 6 times:
    javax.mail.MessagingException: 250 Requested mail action okay, completed
    Does anyone know what might be going on? Thanks in advance for any help you might can give.
    Here is the heart of my code:
    // Get system properties
    Properties props = System.getProperties();
    // Setup mail server
    props.put("mail.smtp.host", host1);
    // 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(fromAddress));
    // Set the to address
    message.addRecipient(Message.RecipientType.TO, new InternetAddress(toAddress));
    // Set the subject
    message.setSubject(subject);
    // Set the content
    message.setContent(content, "text/html");
    // Send message
    Transport.send(message);
    Below is the debugger output: (certain values have been removed for anonymity's sake)
    DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
    DEBUG SMTP: useEhlo true, useAuth false
    DEBUG: SMTPTransport trying to connect to host "xx.xx.xx.xx", port 25
    DEBUG SMTP RCVD: 220 domain.company.com ESMTP MailEnable Service, Version: 1.704-- ready at 01/14/04 14:07:27
    DEBUG: SMTPTransport connected to host "xx.xx.xx.xx", port: 25
    DEBUG SMTP SENT: EHLO licensing
    DEBUG SMTP RCVD: 502
    DEBUG SMTP SENT: HELO licensing
    DEBUG SMTP RCVD: 250-AUTH LOGIN
    250-SIZE 5120000
    250-HELP
    250 AUTH=LOGIN
    DEBUG SMTP: use8bit false
    DEBUG SMTP SENT: MAIL FROM:<[email protected]>
    DEBUG SMTP RCVD: 250 Requested mail action okay, completed
    DEBUG SMTP SENT: RCPT TO:<[email protected]>
    DEBUG SMTP RCVD: 250 Requested mail action okay, completed
    Verified Addresses
    [email protected]
    DEBUG SMTP SENT: DATA
    DEBUG SMTP RCVD: 250 Requested mail action okay, completed
    DEBUG SMTP SENT: QUIT

    But I am getting that code thrown as a MessageException; the message never goes through. If you look at the debugging output compared to a message that went through, the DATA transmission commands are screwed up.
    Thanks for your input, though. I think I've gotten around this by trying to resend the message. It looks like that when I get this exception the message is never sent. I have a catch that detects this exception and tries to resend up to 3 times.
    Thanks,
    floosh

  • Javax.mail.MessagingException: 505 Client was not authenticated

    Hi!,
    I got the following error:
    Exception in thread "main" javax.mail.MessagingException: 505 Client was not authenticated
    at com.sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.java:507)
    at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:312)
    at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:168)
    at HelloMail.main(HelloMail.java:35)
    This is the code:
    To send an email I need authentification, and I include the mail.smtp.auth propertie and
    "message.saveChanges();
    Transport transport = session.getTransport("smtp");
    transport.connect("mail.xxx.com.mx","harriaga",passw);
    transport.sendMessage(message,message.getAllRecipients());
    transport.close();"
    Do you know if I am skip something.
    import java.util.Properties;
    import javax.mail.*;
    import javax.mail.internet.*;
    public class HelloMail {
    public static void main(String args[]) throws Exception {
    String host="mail.xxx.com.mx"; //obviously doesn't work
    String from="[email protected]"; //sender's email
    String to ="[email protected]" ; //receiver's email
    Properties props = System.getProperties();
    props.put("mail.smtp.host", host);
    props.put("mail.smtp.auth", "true");
    Session session=Session.getInstance(props,null);
    MimeMessage message = new MimeMessage(session);
    message.setFrom(new InternetAddress(from));
    message.addRecipient(Message.RecipientType.TO, new
    InternetAddress(to));
    message.setSubject(" My Test HTML email ");
    message.setText(" Here is the content ");
    message.saveChanges();
    Transport transport = session.getTransport("smtp");
    transport.connect("mail.xxx.com.mx","harriaga",passw);
    transport.sendMessage(message,message.getAllRecipients());
    transport.close();
    Thanks for all,
    HAG.

    HAG,
    you need to create a session object passing a valid authenticator. In other words,
    MyAuthenticator auth = new MyAuthenticator ();
    Session session = Session.getInstance(props, auth);where MyAuthenticator is something like
    public class MyAuthenticator extends Authenticator{
      public PasswordAuthentication getPasswordAutentication(){
        return new PasswordAuthentication( "user", "password");
    }You obviously need to replace username and password with data valid for your e-mail account.
    Hope this helps,
    gulfi

  • Javax.mail.MessagingException: 502 unimplemented (#5.5.1)

    hi,
    I am facing a problem in sending mail.
    My program is running on a linux operating system and Tomcat 5.5 .
    So my problem is that when I try to execute that program I get the
    FOLLOWING EXCEPTION.
    I am not getting why that exception is occuring.
    javax.mail.MessagingException: 502 unimplemented (#5.5.1)
    at com.sun.mail.smtp.SMTPTransport.issueCommand SMTPTransport.java:1020)
    at com.sun.mail.smtp.SMTPTransport.helo SMTPTransport.java:630)
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:31 1)
    at javax.mail.Service.connect(Service.java:233)
    at javax.mail.Service.connect(Service.java:134)
    at com.kaizen.Passtori.mail.SendMail.sendMailWithAttachment(SendMail.java:102)
    at com.kaizen.Passtori.UserValidation.UserUtility.sampleRegistration(UserUtility.java:680)
    at org.apache.jsp.jsp.registrationTake_jsp._jspService(org.apache.jsp.jsp.registrationTake_jsp:431)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper .java:322)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3 14)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl icationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF ilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV alve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV alve.java:178)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j ava:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j ava:105)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal ve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav a:148)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java :868)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p rocessConnection(Http11BaseProtocol.java:663)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo int.java:527)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFol lowerWorkerThread.java:80)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP ool.java:684)
    at java.lang.Thread.run(Thread.java:595)
    If anyone knows why this exception is occuring please kindly tell me.
    Its really urgent.
    Thanks and regards
    Rakesh Sagar.

    Run the code using JavaMail's debug mode to see the conversation between your code and the server.
    I don't see the code where you're getting the Session so I can't advise you how to do that, if you don't already know.

  • Javax.mail.MessagingException: Unconnected sockets not implemented

    Hi,
    I am trying to get mails from mail server using IMAP.I am using Jdk 1.5.0.While I am trying to get mails, I am getting following exception.
    DEBUG: setDebug: JavaMail version 1.4.1
    DEBUG: getProvider() returning javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc]
    DEBUG: mail.imap.fetchsize: 16384
    javax.mail.MessagingException: Unconnected sockets not implemented;
    nested exception is:
         java.net.SocketException: Unconnected sockets not implemented
         at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:571)
         at javax.mail.Service.connect(Service.java:288)
         at com.maxis.getmail.receiveEmails(getmail.java:58)
         at com.maxis.getmail.main(getmail.java:22)
    Caused by: java.net.SocketException: Unconnected sockets not implemented
         at javax.net.SocketFactory.createSocket(SocketFactory.java:97)
         at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:225)
         at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
         at com.sun.mail.iap.Protocol.<init>(Protocol.java:107)
         at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:104)
         at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:538)
         ... 3 more
    Here is my code..
    String host = "host";
    String name = "username";
    String passwd = "pwd";
    java.security.Security.setProperty("ssl.SocketFactory.provider", "DummySSLSocketFactory");
    System.setProperty("javax.net.ssl.trustStore"," JAVA_HOME/jre/lib/security/cacert");
    // Get a Properties object
    Properties props = System.getProperties();
    props.setProperty("mail.imaps.ssl.enable", "true");
    props.setProperty("mail.imaps.ssl.socketFactory.class","DummySSLSocketFactory");
    //props.setProperty("mail.imaps.ssl.socketFactory.fallback", "false");
    Session session = Session.getDefaultInstance(props, null);
    session.setDebug(true);
    Store store = session.getStore("imaps");
    store.connect(host,portno ,name, passwd); // exception here
    ===================================================
    I am unable to understand where went wrong. Could someone help me ,Plz?
    Any help would be appreciated.
    Thanks.

    There were some bugs in the old instructions for socket factories. Search this forum for the details.
    But, you should just upgrade to JavaMail 1.4.3, which supports properties that better control SSL
    connections, as well as a MailSSLSocketFactory that will give you more control without having to
    write your own.

  • Error: "javax.mail.MessagingException: 505 5.7.3 Client not Authenticated

    While trying to run a program to sent sms to mobile(with airtel connection)it shows the Error:
    "javax.mail.MessagingException: 505 5.7.3 Client was not Authenticated.
    If anyone knows how to resolve this problem please reply.
    The Code is as follows:
    import java.io.*;
    import java.net.InetAddress;
    import java.util.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    public class EmailSMS
    String TO;
    String FROM;
    String SUBJECT,TEXT,MAILHOST,LASTERROR;
    public static void main(String [] args) throws Exception
         EmailSMS SMS=new EmailSMS();
         SMS.setMailHost("kcsl.com");
         SMS.setTo("[email protected]");
         SMS.setFrom("[email protected]");
         SMS.setSubject("");
         SMS.setText("Hello World");
         boolean ret = SMS.send();
         if(ret){
              System.out.println("SMS was sent");
         else
              System.out.println("SMS was not sent"+SMS.getLastError());
    public EmailSMS()
         TO=null;
         FROM=null;
         SUBJECT=null;
         TEXT=null;
         LASTERROR="No methods calls";
    public void setTo(String to){TO=to;}
    public String getTo(){return TO;}
    public void setFrom (String from){FROM=from;}
    public String getFrom(){ return FROM;}
    public void setSubject(String subject){SUBJECT=subject;}
    public String getSubject(){return SUBJECT;}
    public void setText(String text){TEXT=text;}
    public void setMailHost(String host){MAILHOST=host;}
    public String getMailHost(){return MAILHOST;}
    public String getLastError(){return LASTERROR;}
    public boolean send()
         int maxLength;
         int msgLength;
         //Check to make sure that the parameters are correct
         if(TO.indexOf("mobile.att.net")>0)
              maxLength=140;
         else if(TO.indexOf("messaging.nextel.com")>0)
         {maxLength=280;}
         else if(TO.indexOf("messaging.sprintpcs.com")>0)
         {maxLength=100;}
         else maxLength=160;
         msgLength=FROM.length()+1+SUBJECT.length()+1+TEXT.length();
         if(msgLength>maxLength)
              LASTERROR="SMS length too long";
              return false;
         //set email properties
         Properties props=System.getProperties();
         if(MAILHOST!=null){props.put("mail.smtp.host",MAILHOST);}
         Session session=Session.getDefaultInstance(props,null);
         try{
              Message msg=new MimeMessage(session);
              if(FROM!=null){msg.setFrom(new InternetAddress(FROM));}
              else{msg.setFrom();}
              msg.setSubject(SUBJECT);
              msg.setText(TEXT);
              msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(TO,false));
              msg.setSentDate(new Date());
              Transport.send(msg);
              LASTERROR="Success";
              return true;
         catch(MessagingException max ){LASTERROR=max.getMessage();
         return false;}
    thanku

    Hi,
    it seems to me that you must authenticate with your smtp host. In order to do so, try following:
    While trying to run a program to sent sms to
    mobile(with airtel connection)it shows the Error:
    "javax.mail.MessagingException: 505 5.7.3 Client was
    not Authenticated.
    If anyone knows how to resolve this problem please
    reply.
    The Code is as follows:
    import java.io.*;
    import java.net.InetAddress;
    import java.util.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    public class EmailSMS
    String TO;
    String FROM;
    String SUBJECT,TEXT,MAILHOST,LASTERROR;
    public static void main(String [] args) throws
    Exception
         EmailSMS SMS=new EmailSMS();
         SMS.setMailHost("kcsl.com");
         SMS.setTo("[email protected]");
         SMS.setFrom("[email protected]");
         SMS.setSubject("");
         SMS.setText("Hello World");
         boolean ret = SMS.send();
         if(ret){
              System.out.println("SMS was sent");
         else
    System.out.println("SMS was not
    t sent"+SMS.getLastError());
    public EmailSMS()
         TO=null;
         FROM=null;
         SUBJECT=null;
         TEXT=null;
         LASTERROR="No methods calls";
    public void setTo(String to){TO=to;}
    public String getTo(){return TO;}
    public void setFrom (String from){FROM=from;}
    public String getFrom(){ return FROM;}
    public void setSubject(String
    subject){SUBJECT=subject;}
    public String getSubject(){return SUBJECT;}
    public void setText(String text){TEXT=text;}
    public void setMailHost(String host){MAILHOST=host;}
    public String getMailHost(){return MAILHOST;}
    public String getLastError(){return LASTERROR;}
    public boolean send()
         int maxLength;
         int msgLength;
         //Check to make sure that the parameters are correct
         if(TO.indexOf("mobile.att.net")>0)
              maxLength=140;
         else if(TO.indexOf("messaging.nextel.com")>0)
         {maxLength=280;}
         else if(TO.indexOf("messaging.sprintpcs.com")>0)
         {maxLength=100;}
         else maxLength=160;
         msgLength=FROM.length()+1+SUBJECT.length()+1+TEXT.leng
    h();
         if(msgLength>maxLength)
              LASTERROR="SMS length too long";
              return false;
         //set email properties
         Properties props=System.getProperties();
         if(MAILHOST!=null){props.put("mail.smtp.host",MAILHOST
    Session
    session=Session.getDefaultInstance(props,null);
         try{     // Get a Transport object to send e-mail
                   Transport bus = session.getTransport("smtp");
                   // Connect only once here
                   // Transport.send() disconnects after each send
                   bus.connect(host, username, password);
              Message msg=new MimeMessage(session);
    if(FROM!=null){msg.setFrom(new
    w InternetAddress(FROM));}
              else{msg.setFrom();}
              msg.setSubject(SUBJECT);
              msg.setText(TEXT);
              msg.setRecipients(Message.RecipientType.TO,InternetAd
    ress.parse(TO,false));
              msg.setSentDate(new Date());// Send message
              bus.send(msg);
              bus.close();
              LASTERROR="Success";
              return true;
    catch(MessagingException max
    ){LASTERROR=max.getMessage();
         return false;}
    thankuGood luck

  • Suddenly getting exception - javax.mail.MessagingException: * BYE System

    Hi,
    Suddenly over the last week my application keeps throwing exceptions. This didnt happened before, so the code base hasnt changed! The exception I get is below. Tried searching the internet and tried what was suggested, but this hasnt helped.
    javax.mail.MessagingException: * BYE System Error c63if10001534wej.179;
    nested exception is:
         com.sun.mail.iap.ConnectionException: * BYE System Error c63if10001534wej.179
         at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:616)
         at javax.mail.Service.connect(Service.java:291)

    Just remembered that there are demos with the libraries. I used the msgshow.java example. I changed it so that is just dumped the messages size. I wrapped this in a script so that the msgshow app gets called a 100 times. Anyway I get the same result.
    i.e.
    done 45 times
    Total messages = 444
    New messages = 0
    done 46 times
    Total messages = 444
    New messages = 0
    done 47 times
    Total messages = 445
    New messages = 0
    done 48 times
    Total messages = 445
    New messages = 0
    done 49 times
    Oops, got exception! * BYE System Error w20if10206000wem.32
    javax.mail.MessagingException: * BYE System Error w20if10206000wem.32;
    nested exception is:
         com.sun.mail.iap.ConnectionException: * BYE System Error w20if10206000wem.32
         at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:668)
         at javax.mail.Service.connect(Service.java:295)
         at msgshow.main(msgshow.java:151)
    Caused by: com.sun.mail.iap.ConnectionException: * BYE System Error w20if10206000wem.32
         at com.sun.mail.iap.Protocol.handleResult(Protocol.java:356)
         at com.sun.mail.imap.protocol.IMAPProtocol.login(IMAPProtocol.java:367)
         at com.sun.mail.imap.IMAPStore.login(IMAPStore.java:728)
         at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:648)
         ... 2 more
    done 50 times
    Total messages = 445
    New messages = 0
    done 51 times
    Total messages = 445
    New messages = 0
    Hope someone can help with this.

  • Javax.mail.MessagingException: Unable to load BODYSTRUCTURE

    Hi.
    when i try receive message i have next exception. (But some message recieve without this problem). Can help me?
    Exception with Session debug:
    A12 FETCH 5 (ENVELOPE INTERNALDATE RFC822.SIZE)
    * 5 FETCH (INTERNALDATE "14-Dec-2006 08:46:20 -0500" RFC822.SIZE 35458 ENVELOPE ("Thu, 14 Dec 2006 15:46:13 +0200" "Fwd: Fwd: 123" (("s2mtestAIM" NIL "s2mtest" "aim.com")) (("s2mtestAIM" NIL "s2mtest" "aim.com")) (("s2mtestAIM" NIL "s2mtest" "aim.com")) ((NIL NIL "s2mtest" "aim.com")) NIL NIL "<[email protected]>" "<[email protected]>"))
    A12 OK FETCH completed
    FROM: s2mtestAIM <[email protected]>
    TO: [email protected]
    SUBJECT: Fwd: Fwd: 123
    SendDate: Thu Dec 14 15:46:13 EET 2006
    FLAGS: XAOL-GOODCHECK-DONE
    A13 FETCH 5 (BODYSTRUCTURE)
    * 5 FETCH (BODYSTRUCTURE (("TEXT" "HTML" ("CHARSET" "windows-1251") NIL NIL "QUOTED-PRINTABLE" 4071 146 NIL NIL NIL)("MESSAGE" "RFC822" ("NAME" "1.eml") NIL NIL "7BIT" 13251 NIL ("attachment" ("FILENAME" "1.eml")) NIL)("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 17777 ("Thu, 14 Dec 2006 13:17:25 +0200" "Fwd: 123" (("s2mtestAIM" NIL "s2mtest" "aim.com")) (("s2mtestAIM" NIL "s2mtest" "aim.com")) (("s2mtestAIM" NIL "s2mtest" "aim.com")) ((NIL NIL "s2mtest" "aim.com")) NIL NIL "<[email protected]>" "<[email protected]>") (("TEXT" "HTML" ("CHARSET" "windows-1251") NIL NIL "QUOTED-PRINTABLE" 3103 124 NIL NIL NIL)("MESSAGE" "RFC822" ("NAME" "1.eml") NIL NIL "7BIT" 3723 NIL ("attachment" ("FILENAME" "1.eml")) NIL)("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 1658 ("Thu, 14 Dec 2006 12:36:23 +0200" "123" (("12323" NIL "resetdel" "gmail.com")) (("12323" NIL "resetdel" "gmail.com")) (("12323" NIL "resetdel" "gmail.com")) ((NIL NIL "s2mtest" "aol.com")) NIL NIL NIL "<[email protected]>") ("TEXT" "HTML" ("CHARSET" "windows-1251") NIL NIL "7BIT" 1658 0 NIL NIL NIL) 0 NIL NIL NIL)("TEXT" "HTML" ("CHARSET" "windows-1251") NIL NIL "QUOTED-PRINTABLE" 2063 97 NIL NIL NIL)("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 1697 35 NIL NIL NIL)("TEXT" "HTML" ("CHARSET" "windows-1251") NIL NIL "QUOTED-PRINTABLE" 2063 97 NIL NIL NIL) "MIXED" ("BOUNDARY" "----------87AC1A33733336A") NIL NIL) 440 NIL NIL NIL) "MIXED" ("BOUNDARY" "----------121BF2519BABDF9") NIL NIL))
    A13 OK FETCH completed
    javax.mail.MessagingException: Unable to load BODYSTRUCTURE
         at com.sun.mail.imap.IMAPMessage.loadBODYSTRUCTURE(IMAPMessage.java:1117)
         at com.sun.mail.imap.IMAPMessage.getContentType(IMAPMessage.java:340)
    Thanks.

    Then it's a bug in the AIM IMAP server, please report it.
    I guess this deserves a FAQ entry. Here's what I'll add:
    Q: I can read messages from my IMAP server with other mail clients,
    but even though I can connect to the server using JavaMail, when I use
    JavaMail to read some messages it fails. Doesn't that mean there's a bug
    in JavaMail?
    A: No, not usually. Most other mail clients make very little
    use of the rich IMAP protocol. They use the IMAP protocol as little
    more than a variant of the POP3 protocol, typically downloading the
    entire message to the client and parsing it in the client. This allows
    them to avoid all sorts of parsing and protocol bugs in many IMAP
    servers, but of course it comes at the cost of being less efficient
    because they don't take advantage of the IMAP protocol's ability to
    fetch only the parts of the message that are needed. These server bugs
    often manifest themselves as the following exception on the client:
    javax.mail.MessagingException: Unable to load BODYSTRUCTURE
    The best approach when running into server bugs of this sort is to contact
    the vendor of the server and get them to fix their product. Contact
    [email protected] and we'll help you
    pinpoint the problem so that you can report it to the server vendor.
    If you can't get a fix from the server vendor, the following technique
    will often allow you to work around these server bugs:
        // Get the message object from the folder in the
        // usual way, for example:
        MimeMessage msg = (MimeMessage)folder.getMessage(n);
        // Use the MimeMessage copy constructor to make a copy
        // of the entire message, which will fetch the entire
        // message from the server and parse it on the client:
        MimeMessage cmsg = new MimeMessage(msg);
        // The cmsg object is disconnected from the server so
        // setFlags will have no effect (for example).  Use
        // the original msg object for such operations.  Use
        // the cmsg object to access the content of the message.

  • Javax.mail.MessagingException: A5 BAD Command Argument Error. 12;

    This error appeared on mailboxes hosted on Exchange 2007. It happens when a folder is searched with 11+ OR terms. It works fine with <= 10 subjectTerm items OR'ed together. The search term does not matter. The mailboxes are migrating from Exchange 2003 where the problem does not occur. I tested 51 OR'ed subject terms against the 2003 mailbox and it works fine. I didn't test beyond 51 terms.
    I upgraded to JavaMail 1.4.2 and the problem still exists.
    I'm not sure if this is a JavaMail bug or an error with Exchange 2007.
    Here is the output generated with session debugging enabled against Exchange 2007:
    DEBUG: setDebug: JavaMail version 1.4.2
    DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc]
    DEBUG: mail.imap.fetchsize: 16384
    DEBUG: mail.imap.statuscachetimeout: 1000
    DEBUG: mail.imap.appendbuffersize: -1
    DEBUG: mail.imap.minidletime: 10
    DEBUG: trying to connect to host "qtdenexcam20.ad.domain.com", port 143, isSSL false
    * OK Microsoft Exchange Server 2007 IMAP4 service ready
    A0 CAPABILITY
    * CAPABILITY IMAP4 IMAP4rev1 AUTH=NTLM AUTH=GSSAPI AUTH=PLAIN STARTTLS IDLE NAMESPACE LITERAL+
    A0 OK CAPABILITY completed.
    IMAP DEBUG: AUTH: NTLM
    IMAP DEBUG: AUTH: GSSAPI
    IMAP DEBUG: AUTH: PLAIN
    DEBUG: protocolConnect login, host=qtdenexcam20.ad.domain.com, user=userid, password=<non-null>
    A1 AUTHENTICATE PLAIN
    +
    d21kZXYAd21kZXYAUXczc3QyMDA4
    A1 OK AUTHENTICATE completed.
    A2 CAPABILITY
    * CAPABILITY IMAP4 IMAP4rev1 AUTH=NTLM AUTH=GSSAPI AUTH=PLAIN STARTTLS IDLE NAMESPACE LITERAL+
    A2 OK CAPABILITY completed.
    IMAP DEBUG: AUTH: NTLM
    IMAP DEBUG: AUTH: GSSAPI
    IMAP DEBUG: AUTH: PLAIN
    Opening email folders.
    DEBUG: connection available -- size: 1
    A3 SELECT INBOX
    * 23 EXISTS
    * 0 RECENT
    * FLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)
    * OK [PERMANENTFLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)] Permanent flags
    * OK [UNSEEN 6] Is the first unseen message
    * OK [UIDVALIDITY 765] UIDVALIDITY value
    * OK [UIDNEXT 15790] The next unique identifier value
    A3 OK [READ-WRITE] SELECT completed.
    A4 LIST INBOX ""
    * LIST (\Noselect \HasChildren) "/" ""
    A4 OK LIST completed.
    * OK Microsoft Exchange Server 2007 IMAP4 service ready
    A0 CAPABILITY
    * CAPABILITY IMAP4 IMAP4rev1 AUTH=NTLM AUTH=GSSAPI AUTH=PLAIN STARTTLS IDLE NAMESPACE LITERAL+
    A0 OK CAPABILITY completed.
    IMAP DEBUG: AUTH: NTLM
    IMAP DEBUG: AUTH: GSSAPI
    IMAP DEBUG: AUTH: PLAIN
    A1 AUTHENTICATE PLAIN
    +
    d21kZXYAd21kZXYAUXczc3QyMDA4
    A1 OK AUTHENTICATE completed.
    A2 CAPABILITY
    * CAPABILITY IMAP4 IMAP4rev1 AUTH=NTLM AUTH=GSSAPI AUTH=PLAIN STARTTLS IDLE NAMESPACE LITERAL+
    A2 OK CAPABILITY completed.
    IMAP DEBUG: AUTH: NTLM
    IMAP DEBUG: AUTH: GSSAPI
    IMAP DEBUG: AUTH: PLAIN
    A3 LIST "" Folders/processed_items_LARG
    * LIST (\HasChildren) "/" Folders/processed_items_LARG
    A3 OK LIST completed.
    A4 LIST "" Folders/junk_LARG
    * LIST (\HasNoChildren) "/" Folders/junk_LARG
    A4 OK LIST completed.
    Retrieving all messages from: INBOX
    23 messages retrieved.
    Processing junk email.
    *** Searching for junk mail ***
    A5 SEARCH OR OR OR OR OR OR OR OR OR OR SUBJECT test1 SUBJECT test2 SUBJECT test3 SUBJECT test4 SUBJECT test5 SUBJECT test6 SUBJECT test7 SUBJECT test8 SUBJE
    CT test9 SUBJECT test10 SUBJECT test11 1:23
    A5 BAD Command Argument Error. 12
    Exception caught in main while processing config/email.larg.properties.
    javax.mail.MessagingException: A5 BAD Command Argument Error. 12;
    nested exception is:
    com.sun.mail.iap.BadCommandException: A5 BAD Command Argument Error. 12
    javax.mail.MessagingException: A5 BAD Command Argument Error. 12;
    nested exception is:
    com.sun.mail.iap.BadCommandException: A5 BAD Command Argument Error. 12
    at com.sun.mail.imap.IMAPFolder.search(IMAPFolder.java:1706)
    at com.domain.nroc.email.WMSEmailAgent.processJunkEmail(Unknown Source)
    at com.domain.nroc.email.WMSEmailAgent.main(Unknown Source)
    Caused by: com.sun.mail.iap.BadCommandException: A5 BAD Command Argument Error. 12
    at com.sun.mail.iap.Protocol.handleResult(Protocol.java:338)
    at com.sun.mail.imap.protocol.IMAPProtocol.issueSearch(IMAPProtocol.java:1550)
    at com.sun.mail.imap.protocol.IMAPProtocol.search(IMAPProtocol.java:1458)
    at com.sun.mail.imap.protocol.IMAPProtocol.search(IMAPProtocol.java:1433)
    at com.sun.mail.imap.IMAPFolder.search(IMAPFolder.java:1687)
    ... 2 more
    I'll post the Exchange 2003 debug output in a follow-up message because this message is exceeding the length limit.

    Here is the output generated with session debugging enabled against Exchange 2003 (and 51 subject terms):
    DEBUG: setDebug: JavaMail version 1.4.2
    DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc]
    DEBUG: mail.imap.fetchsize: 16384
    DEBUG: mail.imap.statuscachetimeout: 1000
    DEBUG: mail.imap.appendbuffersize: -1
    DEBUG: mail.imap.minidletime: 10
    DEBUG: trying to connect to host "itdene2km05.ad.domain.com", port 143, isSSL false
    * OK Microsoft Exchange Server 2003 IMAP4rev1 server version 6.5.7638.1 (ITDENE2KM05.AD.DOMAIN.COM) ready.
    A0 CAPABILITY
    * CAPABILITY IMAP4 IMAP4rev1 IDLE LOGIN-REFERRALS MAILBOX-REFERRALS NAMESPACE LITERAL+ UIDPLUS CHILDREN AUTH=NTLM
    A0 OK CAPABILITY completed.
    IMAP DEBUG: AUTH: NTLM
    DEBUG: protocolConnect login, host=itdene2km05.ad.domain.com, user=ad\userid, password=<non-null>
    A1 LOGIN "ad\\userid" pass
    A1 OK LOGIN completed.
    A2 CAPABILITY
    * CAPABILITY IMAP4 IMAP4rev1 IDLE LOGIN-REFERRALS MAILBOX-REFERRALS NAMESPACE LITERAL+ UIDPLUS CHILDREN AUTH=NTLM
    A2 OK CAPABILITY completed.
    IMAP DEBUG: AUTH: NTLM
    Opening email folders.
    DEBUG: connection available -- size: 1
    A3 SELECT INBOX
    * 1 EXISTS
    * 0 RECENT
    * FLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)
    * OK [PERMANENTFLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)] Permanent flags
    * OK [UIDVALIDITY 597925] UIDVALIDITY value
    A3 OK [READ-WRITE] SELECT completed.
    A4 LIST INBOX ""
    * LIST (\Noselect) "/" ""
    A4 OK LIST completed.
    * OK Microsoft Exchange Server 2003 IMAP4rev1 server version 6.5.7638.1 (ITDENE2KM05.AD.DOMAIN.COM) ready.
    A0 CAPABILITY
    * CAPABILITY IMAP4 IMAP4rev1 IDLE LOGIN-REFERRALS MAILBOX-REFERRALS NAMESPACE LITERAL+ UIDPLUS CHILDREN AUTH=NTLM
    A0 OK CAPABILITY completed.
    IMAP DEBUG: AUTH: NTLM
    A1 LOGIN "ad\\userid" pass
    A1 OK LOGIN completed.
    A2 CAPABILITY
    * CAPABILITY IMAP4 IMAP4rev1 IDLE LOGIN-REFERRALS MAILBOX-REFERRALS NAMESPACE LITERAL+ UIDPLUS CHILDREN AUTH=NTLM
    A2 OK CAPABILITY completed.
    IMAP DEBUG: AUTH: NTLM
    A3 LIST "" Folders/processed_items_LARG
    * LIST (\HasChildren) "/" Folders/processed_items_LARG
    A3 OK LIST completed.
    A4 LIST "" Folders/junk_LARG
    * LIST (\HasNoChildren) "/" Folders/junk_LARG
    A4 OK LIST completed.
    Retrieving all messages from: INBOX
    1 messages retrieved.
    Processing junk email.
    *** Searching for junk mail ***
    A5 SEARCH OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR
    OR SUBJECT test1 SUBJECT test2 SUBJECT test3 SUBJECT test4 SUBJECT test5 SUBJECT test6 SUBJECT test7 SUBJECT test8 SUBJECT test9 SUBJECT test10 SUBJECT test1
    1 SUBJECT test12 SUBJECT test13 SUBJECT test14 SUBJECT test15 SUBJECT test16 SUBJECT test17 SUBJECT test18 SUBJECT test19 SUBJECT test20 SUBJECT test21 SUBJE
    CT test22 SUBJECT test23 SUBJECT test24 SUBJECT test25 SUBJECT test26 SUBJECT test27 SUBJECT test28 SUBJECT test29 SUBJECT test30 SUBJECT test31 SUBJECT test
    32 SUBJECT test33 SUBJECT test34 SUBJECT test35 SUBJECT test36 SUBJECT test37 SUBJECT test38 SUBJECT test39 SUBJECT test40 SUBJECT test41 SUBJECT test42 SUBJ
    ECT test43 SUBJECT test44 SUBJECT test45 SUBJECT test46 SUBJECT test47 SUBJECT test48 SUBJECT test49 SUBJECT test50 SUBJECT "Exchange Maintenance" 1
    * SEARCH 1
    A5 OK SEARCH completed.
    1 junk email items identified.
    A5 LIST "" Folders/junk_LARG

  • Send mail through Java program. ERROR javax.mail.MessagingException: [EOF]

    Hi,
    i've a java Mail program which will send the mail thro smtp server.
    when i try to execute this program im getting the error javax.mail.MessagingException: [EOF]
    i've attached both code & error.
    while running the program need to give the arguments
    ex : java SendMail smtpserver frommailid tomailid subject body
    please provide me the solution.
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;
    public class SendMail {
         public static void main(String[] args) {
              try
         String smtpServer=args[0];
         String to=args[1];
         String from=args[2];
         String subject=args[3];
         String body=args[4];
         send(smtpServer, to, from, subject, body);
         catch (Exception ex)
         System.out.println("Usage: java SendMail"
         +" smtpServer toAddress fromAddress subjectText bodyText");
         System.exit(0);
         public static void send(String smtpServer, String to, String from
                   , String subject, String body)
                   try
                   Properties props = System.getProperties();
                   props.put("mail.smtp.host", smtpServer);
                   Session session = Session.getDefaultInstance(props, null);
                   Message msg = new MimeMessage(session);
                   msg.setFrom(new InternetAddress(from));
                   msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to, false));
                   msg.setSubject(subject);
                   msg.setText(body);
                   msg.setSentDate(new Date());
                   System.out.println("test 1--");
                   Transport.send(msg);
                   System.out.println("test 2--");
                   System.out.println("Message sent OK.");
                   catch (Exception ex)
                   ex.printStackTrace();
    thanks for the help in advance.
    regs
    lal.

    I ran into a similar error today. I fixed it by setting up SMTP authentication because my ISP's help pages said that they would allow only SMTP authentication.
    Here is what I did:
    Transport transport =
    mailConnection.getTransport("smtp");
    transport.connect(
    "hostname", "email", "password");
    Transport.send(msg);
    I also passed the following property while creating the session:
    props.put("mail.smtp.auth", "true");
    finally turning on debug helped:
    session.setDebug(true);
    session.setDebugOut(null);
    Hope this helps

  • Sockets:  Connection refused: connect

    Hello,
    I try to create to apps one is server the other client
    I inserted the code below.
    This is the server code:
    ServerSocket serverSocket = new ServerSocket(87);
    Socket s;
    s = serverSocket.accept();
    boolean b = true;
    while (b)
      s = serverSocket.accept();
      System.out.println("Connection from " + s.getInetAddress().getHostName());
      BufferedReader bf = new BufferedReader(new InputStreamReader(s.getInputStream()));
      BufferedWriter br = new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
      BufferedReader consoleReader = new BufferedReader(new InputStreamReader(System.in));
      ObjectOutputStream oo = new ObjectOutputStream(s.getOutputStream());
      String str = bf.readLine();
      if (str != null)               
         System.out.println("Incomming message: " + str);               
         String consoleInput = consoleReader.readLine();
         if (consoleInput != null)
            oo.writeObject(consoleInput);
            oo.flush();
         else
            if (consoleInput.equals("stop"))
              oo.writeObject("Server will stop");
              oo.flush();
              b = false;
    }This is the client:
    Socket client = new Socket("localhost",87);
    BufferedReader br = new BufferedReader(new InputStreamReader(client.getInputStream()));
    boolean b = true;
    while (b)
       String str = br.readLine();
       if (str != null)
           System.out.println("receive message: " + str);
           if ( str.equals("Server will stop"))
              b =false;
    }The server starts up. But the client gives an java.net.ConnectException: Connection refused: connect
    Client is only listening to what the server is sending.
    The server send what's entered on the console.
    Can somebody tell me what I'm doin wrong?
    Thanks a lot
    Dries

    Here are the exact files that I used and are running on my machine:
    // Client.java
    import java.io.*;
    import java.net.*;
    public class Client
         public static void main(String args[]) throws Exception
              Socket client = new Socket("localhost",6655);
              BufferedReader br = new BufferedReader(new InputStreamReader(client.getInputStream()));
              boolean b = true;
              while (b)
                 String str = br.readLine();
              if (str != null)
                     System.out.println("receive message: " + str);
              if ( str.equals("Server will stop"))
                        b =false;
    //Server.java
    import java.io.*;
    import java.net.*;
    public class Server
         public static void main(String args[]) throws Exception
              ServerSocket serverSocket = new ServerSocket(6655);
         System.out.println("Bind done");
              Socket s;
              s = serverSocket.accept();
              boolean b = true;
              while (b)
                System.out.println("Connection from " + s.getInetAddress().getHostName());
                BufferedReader bf = new BufferedReader(new InputStreamReader(s.getInputStream()));
                BufferedWriter br = new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
                BufferedReader consoleReader = new BufferedReader(new InputStreamReader(System.in));
                ObjectOutputStream oo = new ObjectOutputStream(s.getOutputStream());
                String str = bf.readLine();
              if (str != null)
                    System.out.println("Incomming message: " + str);
                    String consoleInput = consoleReader.readLine();
              if (consoleInput != null)
                   oo.writeObject(consoleInput);
                   oo.flush();
              else
              if (consoleInput.equals("stop"))
                     oo.writeObject("Server will stop");
                     oo.flush();
                     b = false;
    }Then, in one window, start "Server" and another start "Client". It works for me on Windows 2K system.

Maybe you are looking for

  • N79 or N82

    Hello all, i am gonna be getting one of these two and i had a few questions 1. Which is better for texting? 2. Which has the better audio quality through the 3.5mm jack? 3. How reliable are they? Are there any current firmware crashes,lock ups, reset

  • Can i have the same Apple-Id-Account to two iPhone?

    Can i have the same Apple Id Account to two iPhone? Or do I need to get a new one? With iPod you can have more than one to the same ID? Regards , Yvonne

  • SAP Query Alias Table in Info-set not working

    Hi Guys, I'm having a bit of trouble with a query I'm writing in SQ01. I am trying to create a standard margin report between two different costing variants that we use. n order to do so I have had to employ the use of alias tables. I have named the

  • Wifi extending issue as well as NAS off-site.

    Having a couple of issues I'm trying to work around. Hope someone here can help me out. I'm not sure if this is a two part question or can be combined. I have a garden office which I'm about to start working from. It's about 30-35m from the back of m

  • Re-importing FDM application from XML not removing deleted objects/records

    I migrated our FDM application from one environment to the next environment, by exporting the FDM application from the source environment to an XML file and subsequently importing the FDM application XML file in the target environment. This appeared