posted 18 years ago
I am getting the following error when I try to send a mail using JAVAMAIL API.
javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;
Following is the code snippet I am using:
Properties p = new Properties();
p.put("mail.smtp.user", mailuser);
p.put("mail.smtp.host", mailhost);
p.put("mail.smtp.port", "558");
p.put("mail.smtp.debug", "true");
try {
session = Session.getDefaultInstance(p);
MimeMessage msg = new MimeMessage(session);
msg.setText(text);
msg.setSubject(subject);
Address fromAddr = new InternetAddress(mailuser);
msg.setFrom(fromAddr);
Address toAddr = new InternetAddress(_to);
msg.addRecipient(Message.RecipientType.TO, toAddr);
System.out.println("Message: " + msg.getContent());
Transport.send(msg);
}
catch (Exception mex) {// Prints all nested exceptions as well
System.out.println("I am here??? ");
mex.printStackTrace();
}
// Note: will use results of getLocalHost() to fill in EHLO domain
}
1. I am suspecting that my DSL service (VZavenue) has bloced port 25 and hence it is throwing that error. is that correct?
2. In my code I tried to change the port and the hostname yet the error is saying localhost and port 25. Why?
3. Is there a work-around to this in case my VZAvenue is in fact blocking port 25? if not, do they unblock this port if I contact them?
Appreciate your help in resolving this problem.
Thanks,
Venkat