• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Port of SMTP

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have been trying to send a mail from my application. It tries and fails every time giving an exception

Cannot send email. javax.mail.SendFailedException: Sending failed;
nested exception is:
javax.mail.MessagingException: Could not connect to SMTP host: inmumm05.tcs.com, port: 25
javax.mail.SendFailedException: Sending failed;

I have a property file which contains all the data to be sent. Here I have mentioned the port number but it does not seem to have an effect. It always says port 25. Please help.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does inmumm05.tcs.com accept connections on port 25? If it does, can you show us the code where you apply your Java Mail properties and the contents of your properties file?
 
Naresh Rajan
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No it does not accept. I tried it out. I tried printing the contents of the Property file and it prints the value properly but it does not pass on the value to Transport.

I actually took the code from the net. It is available at

http://www.javapractices.com/Topic144.cjp

It needs the mail.jar and activation.jar in the classpath

Regards.
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The best way to find whether a port is action in a particular host is by telneting.

Telnet host port

if connection not refused then thats a listening port in the host.
 
Naresh Rajan
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Rahul. I found out that the port number. But still my application seems to have a problem. Is there any problem regarding my protocol???
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From the exception it seems like its not able to connect to the host.

Have you tried the telnet stuff?

One more thing to check would be whether the name to IP resolution is taking place properly.If not you can use the IP directly in place of host to see what happens.
 
Naresh Rajan
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rahul,
I tried the telnet stuff and it is connecting. but my application is not working. I cannot get the IP address. The name is correct though!!
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Naresh Rajan:
Rahul,
I tried the telnet stuff and it is connecting. but my application is not working. I cannot get the IP address. The name is correct though!!



try the following to get the IP address

ping <your_machine_name>

The response will have something like
Pinging with x bytes <your_machine_name> [your_IP]
Now use your_IP
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rahul Bhattacharjee wrote:

Originally posted by Naresh Rajan:
Rahul,
I tried the telnet stuff and it is connecting. but my application is not working. I cannot get the IP address. The name is correct though!!



try the following to get the IP address

ping <your_machine_name>

The response will have something like
Pinging with x bytes <your_machine_name> [your_IP]
Now use your_IP



Hi even i am facing the same problem, even if i replace HostName with the IP of the server , i am getting the same error.

javax.mail.MessagingException: Could not connect to SMTP host: 10.35.55.203, port: 25, response: -1
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1270)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370)
at javax.mail.Service.connect(Service.java:275)
at com.jnj.email.p.MailSender.sendMail(MailSender.java:59)
at com.jnj.email.p.MailSender.main(MailSender.java:23)
Could you please help?

I can ping the server, i can telnet the server with port 25, everything is fine. but SAME ERROR.

 
Rancher
Posts: 4804
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Manish Narang wrote:
javax.mail.MessagingException: Could not connect to SMTP host: 10.35.55.203, port: 25, response: -1
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1270)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370)
at javax.mail.Service.connect(Service.java:275)
at com.jnj.email.p.MailSender.sendMail(MailSender.java:59)
at com.jnj.email.p.MailSender.main(MailSender.java:23)
Could you please help?



The error message is actually quite informative. That server is not answering on port 25.
You need to contact that host's admin and see if they support SMTP input, and if so, do they require TLS, SSH, etc.

Its not a programming error, its an admin/usage issue
 
Manish Narang
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Pat Farrell wrote:

Manish Narang wrote:
javax.mail.MessagingException: Could not connect to SMTP host: 10.35.55.203, port: 25, response: -1
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1270)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370)
at javax.mail.Service.connect(Service.java:275)
at com.jnj.email.p.MailSender.sendMail(MailSender.java:59)
at com.jnj.email.p.MailSender.main(MailSender.java:23)
Could you please help?



The error message is actually quite informative. That server is not answering on port 25.
You need to contact that host's admin and see if they support SMTP input, and if so, do they require TLS, SSH, etc.

Its not a programming error, its an admin/usage issue



Thanks for your reply Farrell..!
Pat Farrell: The scenario is like, we use the same smtp host in our all three env's (DEV, TEST, PROD). This program runs FINE in Production servers but not in others..
so can it be a problem with the smtp host server or DEV and TEST servers ?
i mean should contact the team which supports smtp host or DEV/TEST servers ?
 
Pat Farrell
Rancher
Posts: 4804
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Manish Narang wrote:The scenario is like, we use the same smtp host in our all three env's (DEV, TEST, PROD). This program runs FINE in Production servers but not in others..
so can it be a problem with the smtp host server or DEV and TEST servers ?
i mean should contact the team which supports smtp host or DEV/TEST servers ?



Yes, perhaps they are not running Postfix or sendmail on the dev/test servers.
 
Sheriff
Posts: 28328
96
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Manish Narang wrote:Thanks for your reply Farrell..!
Pat Farrell: The scenario is like, we use the same smtp host in our all three env's (DEV, TEST, PROD). This program runs FINE in Production servers but not in others..
so can it be a problem with the smtp host server or DEV and TEST servers ?
i mean should contact the team which supports smtp host or DEV/TEST servers ?



Sounds to me like the people who manage the SMTP server have configured it to only accept requests from specific machines. If this were my problem I wouldn't be asking random strangers to speculate about the problem, though, I would be asking the SMTP server managers.
 
Manish Narang
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
My problem is solved. Just wanted to inform that the problem was: "SMTP Relay was not enabled for our TEST and DEV servers on the SMTP HOST". requested them to enable it and it works great...!!!

Thanks all for your help!!!

 
Their achilles heel is the noogie! Give them noogies tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic