cannot connect to smtp host

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nickyeng
    Contributor
    • Nov 2006
    • 252

    cannot connect to smtp host

    i know alot of people faced this problem before.
    i searched google.com i search javaranch.com, no one article can help me solve the problem.
    I runs it in my localhost server, it runs well.
    But when i runs it in my company's server, it give this error :
    ----
    javax.mail.Send FailedException : Sending failed; nested exception is: class javax.mail.Mess agingException: Could not connect to SMTP host: mail.as.com.my, port: 25; nested exception is: java.net.Connec tException: Connection timed out: connect
    ----

    i used telnet to ping the mail server, it was okay and give me 220. This is in localhost.
    But when i try to telnet the mail server in company's remote pc, it said cannot open a connection to host on port 25

    could someone list down the possible causes so that i and everyone else can know how many possible causes for this problem.

    I'll really appreciate if someone can help..
    thanks in advance.

    ~Nick

    Code:
    String message = "halo" + " world";
    Properties props = new Properties();
    props.put("mail.smtp.port", "25");
    props.put("mail.smtp.host","mail.as.com.my");
        	
    
    // create some properties and get the default Session
    Session ss = Session.getInstance(props, null);
    ss.setDebug(true);
        	
    
    MimeMessage msg = new MimeMessage(ss);
    
    InternetAddress addressfrom = new InternetAddress("info@as.com.my");
    msg.setFrom(addressfrom);
        	
    InternetAddress addressTo = new InternetAddress(to);
    msg.addRecipient(Message.RecipientType.TO, addressTo);
    
    msg.setSubject(subject);
    msg.setContent(message, "text/plain");
    
    Transport.send(msg);
  • etiainen
    New Member
    • Aug 2007
    • 40

    #2
    Well, I can't telnet the host either. You might wanna check if its domain name is properly registered.
    Try using ip number in your code...
    Before I tried this one of my guesses was that your company network might be blocking trafic over port 25. You might check that too, but I think DNS is the problem.

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      Originally posted by etiainen
      Well, I can't telnet the host either. You might wanna check if its domain name is properly registered.
      I guess the OP doesn't want to shows us the real name of his/her smtp server;
      I don't recognize the top level domain name of "mail.as.com.my "; and indeed
      it can't be ping'd nor telnet'd at all.

      kind regards,

      Jos

      Comment

      • nickyeng
        Contributor
        • Nov 2006
        • 252

        #4
        Originally posted by JosAH
        I guess the OP doesn't want to shows us the real name of his/her smtp server;
        I don't recognize the top level domain name of "mail.as.com.my "; and indeed
        it can't be ping'd nor telnet'd at all.

        kind regards,

        Jos
        yeah, you're right.
        i didn't show the correct name.

        by the way, i settled this problem already.
        My company block on port 25 and any connection to it.
        It is settled using my director's mail code.

        thanks anyway.

        Comment

        Working...