• Post Reply Bookmark Topic Watch Topic
  • New Topic

can not connect -imeout  RSS feed

 
Mariusz Bogucki
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can somebody tell me why cant I connect to the server and why I am getting this error message?
java.lang.Exception: Could not connect to SMTP host: smtp.gawab.com, port: 25;
nested exception is:
java.net.ConnectException: Connection timed out: connect


I am awriting here because i have already tried three different servers that offer pop3 and could not connect to any of them so is it my code or the server problem?

Itried gwab.com runbox.com and sth else dont remember...

/*
* MailerBean.java
*
* Created on June 8, 2005, 2:56 PM
*/

package uploader;
import java.io.*;
import java.util.*;
import javax.mail.*;
import javax.mail.event.*;
import javax.mail.internet.*;

public final class MailerBean extends Object implements Serializable {

/* Bean Properties */
private String to ="inzaoquan@aol.com";
private String from ="superlobo@gawab.com";
private String subject = "ok";
private String message = "oki";
public static Properties props = null;
public static Session session = null;







public void sendMail() throws Exception {

props = System.getProperties();
props.put("mail.smtp.host", "smtp.gawab.com");
session = Session.getDefaultInstance(props, null);

try {
MimeMessage message = new MimeMessage(session);
message.setRecipient(Message.RecipientType.TO,
new InternetAddress(this.to));
message.setFrom(new InternetAddress(this.from));
message.setSubject(this.subject);
message.setText(this.message);
Transport.send(message);
} catch (MessagingException e) {
throw new Exception(e.getMessage());
}
}

/* Checks whether all properties have been set or not */

}
[ June 08, 2005: Message edited by: Mariusz Bogucki ]
 
Mariusz Bogucki
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok I 've figured that out, I tried to connect by the telnet on that port and it did not respond either so I found out that it will accept connection on port 26, but the default port is 25 and I dont know how to change it?
anybod knows?
I could not find it in the API
 
Amit Siinngghh
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I found this code in the pdf document from the sun's website

// Get a Session object
Session session = Session.getDefaultInstance(props, null);
session.setDebug(debug);
// Get a Store object
Store store = null;
if (url != null) {
URLName urln = new URLName(url);
store = session.getStore(urln);
store.connect();
}

Constructor for URLName: URLName(java.lang.String protocol, java.lang.String host, int port, java.lang.String file, java.lang.String username, java.lang.String password)


There might be another way, i.e. connecting to the POP3Store

I think you can connect to the POP3Store directly

Constructor : POP3Store(Session session, URLName url, java.lang.String name, int defaultPort, boolean isSSL)


let us know how it goes

good luck
-Amit
 
Jeffrey Spaulding
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
props.put("mail.smtp.port", "" + smtpPort);
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!