Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

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

843830Jun 18 2007 — edited Jun 19 2007
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;

public class MailControl {

	public astech.b2b.mail.Msg SuppMail = null;
	protected java.lang.String fullFileName = null;
	protected String key = null;
	protected int id = 0;
	protected int prcTyp = 0;

	/**
	 * Constructor for MailControl.
	 */
	public MailControl() {
		super();
	}

	public MailControl(int id, int pT) {
		super();
		this.id = id;
		prcTyp = pT;
	}

	public boolean 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;
		}

public void 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;
}

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

public void setSuppMail(astech.b2b.mail.Msg newValue) {
	this.SuppMail = newValue;}

public static void main(String args[]) {
	MailControl MC = new MailControl();
	MC.mailItNow();
	}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 17 2007
Added on Jun 18 2007
4 comments
223 views