javax.mail.MessagingException: Could not connect to SMTP host: 172.20.10.11

Hi there,

I wonder if you could help, I've tried searching the FAQ's and around the internet for a solution to this.

When I run the code below I get the following error..

javax.mail.MessagingException: Could not connect to SMTP host: 172.20.10.110, port: 25, response: -1

I can't seem to find what the "respone: -1" means, I've tried a few different versions of a mail sender program (to make sure that it's not anything I have coded incorrectly), but always get the same results.

I've also tried changing my connection details so that I use my bt-internet email account rather than my company email account and still keep getting the same errors.

package email;

import javax.mail.MessagingException;

publicclass MailControl{

public astech.b2b.mail.Msg SuppMail =null;

protected java.lang.String fullFileName =null;

protected String key =null;

protectedint id = 0;

protectedint prcTyp = 0;

/**

* Constructor for MailControl.

*/

public MailControl(){

super();

}

public MailControl(int id,int pT){

super();

this.id = id;

prcTyp = pT;

}

publicboolean mailDetails(){

boolean active =false;

astech.b2b.mail.Msg mail =new astech.b2b.mail.Msg();

mail.addRecipient("servicedesk@astech.uk.com");// Load the To email address

mail.setSender("clomas@astech.uk.com");// Load the From email address

mail.setHost("dell2003.Astech.local");// Set Host Mail Server

mail.setSubjectText("Have the back-up tapes been changed?");// Set the email subject

mail.setMsgText("Testing text");// Set the message body

mail.setUserid("clomas");// Load the user id

mail.setPassword("password");// Load the user password

mail.setAuthorizationRequired(true);

setSuppMail(mail);

active =true;

return active;

}

publicvoid attachFile(){

// Set the file URL to the file name

if (fullFileName !=null){

String[] attachedFile ={ fullFileName};

getSuppMail().setAttachedFiles(attachedFile);

}

}

public astech.b2b.mail.Msg getSuppMail(){

return SuppMail;

}

publicvoid mailItNow(){

try{

if (mailDetails()){

attachFile();

astech.b2b.mail.SendMail sm =new astech.b2b.mail.SendMail();

sm.sendIt(getSuppMail());

}else{

// throwException(

//new OutboundFileException("No valid (or inactive) mail details have been setup for this vendor."));

}

}catch (MessagingException e){

System.out.println(e);

System.out.println(e.getNextException());

}

}

publicvoid setSuppMail(astech.b2b.mail.Msg newValue){

this.SuppMail = newValue;}

publicstaticvoid main(String args[]){

MailControl MC =new MailControl();

MC.mailItNow();

}

}

[5800 byte] By [hockeygod76a] at [2007-11-27 7:59:15]
# 1

Did you try the connection debugging tips in the JavaMail FAQ?

Most likely a firewall somewhere is preventing you from connecting

using port 25. Some companies will prevent such connections so that

infected zombie PCs in the company can't send spam outside the

company.

bshannona at 2007-7-12 19:41:17 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
check the firewalls in ur system.the code is correct .some one not allowing to access the smtpi think this will help u
prasanit2005a at 2007-7-12 19:41:17 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

I sopke to one of our server admins and he seems to think I should be able to connect to the exchange server.

While I was trying a few things out yesterday I tried connecting on different port numbers and managed to get a different error message when connecting on port 88 - after a while I got a connection reset error.

What I may do is try running my code on my laptop at home and see if I get any further - that way I can rule out company network problems.

hockeygod76a at 2007-7-12 19:41:17 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4
> I sopke to one of our server admins and he seems to> think I should be able to connect to the exchange> server."Seems to think"? He didn't go to the machine in question and do the ping and telnet tests to verify?
DrClapa at 2007-7-12 19:41:17 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...