java.net.ConnectException: Connection refused

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • deepthisoft
    New Member
    • Jul 2007
    • 27

    java.net.ConnectException: Connection refused

    hai ,

    I have created an application using javamail for the purpose of send the mail.
    Mail goes all the mail ids , if i use our company domain name.If i use other domain like yahoo,gmail and other company domain names. I got the following error.
    could not connect to SMTP host port 25.
    java.net.Connec tException: Connection refused

    How to solve this problem.
    This is very urgent for me.
    Anybody can help me.
    Thanks in advance....
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    Originally posted by deepthisoft
    hai ,

    I have created an application using javamail for the purpose of send the mail.
    Mail goes all the mail ids , if i use our company domain name.If i use other domain like yahoo,gmail and other company domain names. I got the following error.
    could not connect to SMTP host port 25.
    java.net.Connec tException: Connection refused

    How to solve this problem.
    This is very urgent for me.
    Anybody can help me.
    Thanks in advance....
    Paste your code.
    Then I ll make you understand you.

    Kind regards,
    Dmjpro.

    Comment

    • deepthisoft
      New Member
      • Jul 2007
      • 27

      #3
      hai,

      My code is like this,
      [code=java]
      String from="myname@do main.com";
      String fromId = "myid@domain.co m";
      String password = "mypassword ";

      Authenticator auth = new PopupAuthentica tor(fromId, password);
      java.util.Prope rties props = System.getPrope rties();
      props.put("mail .smtp.host", "mail.gmail.com ");
      props.put("mail .pop3.host", "mail.gmail.com ");
      //instead of these i use our company domain it works fine.
      props.put("mail .smtp.port", "25");

      props.put("mail .transport.prot ocol", "smtp");
      props.put("mail .smtp.auth", "true");
      Session session = Session.getInst ance(props, auth);
      session.setDebu g(false);

      Transport transport = session.getTran sport("smtp");

      com.sun.mail.sm tp.SMTPMessage msg = new com.sun.mail.sm tp.SMTPMessage( session);
      MimeMessage message = new MimeMessage(ses sion);
      //-- Set the from and to address --
      InternetAddress[] address=Interne tAddress.parse( m,false);
      message.addReci pients(Message. RecipientType.T O,address);
      message.setFrom (new InternetAddress (from));
      message.setSubj ect("");
      Transport.send( message);
      [/code]



      Thanks in advance...

      Comment

      Working...