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();
}
}

