| Author |
JavaMail - Port 25 blocked?
|
Venkata Avasarala
Greenhorn
Joined: Sep 26, 2005
Posts: 2
|
|
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
|
 |
Michael Ernest
High Plains Drifter
Sheriff
Joined: Oct 25, 2000
Posts: 7292
|
|
|
Are you sure that a mail service is running on port 25 for your machine?
|
Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
|
 |
Arun Prasath
Ranch Hand
Joined: Sep 17, 2003
Posts: 192
|
|
|
If you run a mail service on your "localhost", and still you get the error, you can check that by connecting to localhost using telnet on port 25.
|
SCJP 1.4, SCDJWS , SCJA<br />I can do ALL things through CHRIST who strengthens me.
|
 |
Venkata Avasarala
Greenhorn
Joined: Sep 26, 2005
Posts: 2
|
|
Hi there, Not sure what you mean by whether a mail service is running on that port. I don't think it is. I ran the port trace from hackerwhacker.com and it did show that port 25 is blocked. Thanks, Venkat
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12929
|
|
> Not sure what you mean by whether a mail service is running on that port. Your program needs to connect to a mail server. The way you're doing it now, your program is trying to connect to "localhost" (your local machine). If you don't have a mail server running on your computer, then it can't connect (there is no mail server listening on port 25 on your computer). Change the hostname to something else than "localhost" or setup a mail server on your local computer. If you're only doing things on your local computer, your ISP has nothing to do with it. [ September 29, 2005: Message edited by: Jesper de Jong ]
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
 |
|
|
subject: JavaMail - Port 25 blocked?
|
|
|