sending an email in java: (help a Beginner !)
hi,
i am new to java mail and trying to send a test mail and here's my code
Properties props = new Properties();
props.put("mail.host"," smtp ");
Session mail = Session.getInstance(props,null);
mail.setDebug(true);
final Message msg = new MimeMessage(mail);
Address to = new InternetAddress("to");
Address from = new InternetAddress("from");
msg.setFrom(from);
msg.setRecipient(Message.RecipientType.TO,to);
msg.setSubject("Java TEST ");
Transport.send(msg);
(with the assumption that i have correct details of the server and to and from addresses)
but i get the following exception :
javax.mail.SendFailedException: Sending failed;
nested exception is:
class javax.mail.MessagingException: Could not connect to SMTP host: smtp.host, port: 25;
nested exception is:
java.net.NoRouteToHostException: No route to host: connect
(oh, and i also have the try and catch thing for the code)
can u help?
thx