• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JavaMail - Port 25 blocked?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
High Plains Drifter
Posts: 7289
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you sure that a mail service is running on port 25 for your machine?
 
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Venkata Avasarala
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> 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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic