czh81
asked on
javamail exception Could not connect to SMTP host: smtp.myhost.com, port: 25, response: -1
I tried to use javamail to send email from java file
I tried to turn off my Norton AntiVirus, but still not work
I can telnet my mail host with port 25 so looks like the port 25 is available
I can go to my mail host's web site login with my user name and password.
What response -1 means?
what else could be wrong?
I can ping my email server(it is working).
My laptop is Windows XP . My labtop connects to Internet throgh RCN internet service.
I did go to this website http://scan.sygate.com/
to check, it said port 25 not open
I went to control panel-security center and it said Firewall not monitored.(so it means the firewall already been disabled)
Start -> Run -> cmd -> telnet myhost.com:25 will shows connection to myhost.com could not open connection to the
host on port 23: connection failed (why it says port 23 I don't understand)
if I try this Start -> Run -> cmd -> telnet myhost.com 25 it will open another window but shows nothing
Can somebody user your smpt host info to run my code to see if it is my code's problem or something else.
Maybe my ISP blocked port 25. If so how can I open it?
javax.mail.MessagingExcept ion: Could not connect to SMTP host: smtp.myhost.com, port: 25, response: -1
at com.sun.mail.smtp.SMTPTran sport.open Server(SMT PTransport .java:1215 )
at com.sun.mail.smtp.SMTPTran sport.prot ocolConnec t(SMTPTran sport.java :322)
my code:********************* ********** ********** *****
public class sendmail3 {
public static void main(String arg[])
{
//Get system properties
Properties props = System.getProperties();
Session session = Session.getDefaultInstance (props, null);
// Setup mail server
java.util.Properties sessionProperties = new java.util.Properties();
sessionProperties.put("mai l.smtp.aut h", "true");
sessionProperties.put("mai l.smtp.por t", "25");
// Define message
javax.mail.internet.MimeMe ssage message = new javax.mail.internet.MimeMe ssage(sess ion);
try{
message.setFrom(new javax.mail.internet.Intern etAddress( "mymail@my host.com") );
message.addRecipient(
javax.mail.Message.Recipie ntType.TO,
new javax.mail.internet.Intern etAddress( "czh81@hot mail.com") );
message.setSubject("test") ;
message.setContent("this is a test", "text/plain");
// Send message - This is the line that causes the smtp debug and the network activity
Transport t = session.getTransport("smtp ");
t.connect("smtp.myhost.com ", "myusername","mypasswor") ;
// send the message
Transport.send(message);
}
catch(Exception e)
{
e.printStackTrace();
}
}
I tried to turn off my Norton AntiVirus, but still not work
I can telnet my mail host with port 25 so looks like the port 25 is available
I can go to my mail host's web site login with my user name and password.
What response -1 means?
what else could be wrong?
I can ping my email server(it is working).
My laptop is Windows XP . My labtop connects to Internet throgh RCN internet service.
I did go to this website http://scan.sygate.com/
to check, it said port 25 not open
I went to control panel-security center and it said Firewall not monitored.(so it means the firewall already been disabled)
Start -> Run -> cmd -> telnet myhost.com:25 will shows connection to myhost.com could not open connection to the
host on port 23: connection failed (why it says port 23 I don't understand)
if I try this Start -> Run -> cmd -> telnet myhost.com 25 it will open another window but shows nothing
Can somebody user your smpt host info to run my code to see if it is my code's problem or something else.
Maybe my ISP blocked port 25. If so how can I open it?
javax.mail.MessagingExcept
at com.sun.mail.smtp.SMTPTran
at com.sun.mail.smtp.SMTPTran
my code:*********************
public class sendmail3 {
public static void main(String arg[])
{
//Get system properties
Properties props = System.getProperties();
Session session = Session.getDefaultInstance
// Setup mail server
java.util.Properties sessionProperties = new java.util.Properties();
sessionProperties.put("mai
sessionProperties.put("mai
// Define message
javax.mail.internet.MimeMe
try{
message.setFrom(new javax.mail.internet.Intern
message.addRecipient(
javax.mail.Message.Recipie
new javax.mail.internet.Intern
message.setSubject("test")
message.setContent("this is a test", "text/plain");
// Send message - This is the line that causes the smtp debug and the network activity
Transport t = session.getTransport("smtp
t.connect("smtp.myhost.com
// send the message
Transport.send(message);
}
catch(Exception e)
{
e.printStackTrace();
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
it is working now. The reason I can not send email because my ISP 's issue. I have to put my ISN's smtp address as my host.
Thanks for help.
Thanks for help.
ASKER