• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Could not connect to SMTP host: localhost, port: 25

 
Matthew McHale
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am in the process of moving several applications from Websphere App server to Tomcat. I've had an email function in my appolication for a long while with no trouble. Now, I have an intermittent problem occuring when I try to use JavaMail to send email. It works sometimes and not others. It appears to be related to system resources in some way because the problem arises after the server has been running for a few hours. I increased the heap size and the MaxPermSize, but there doesn't really seem to be a shortage in memory according to Lambda Probe. It still happens on and off. There are also a few other web apps running on this instance as well.

Below is the stack trace and the JavaMail code.

Please Help!
Matt

Properties props = System.getProperties();
props.put("mail.smtp.host", this.smtpServer);
Session session = Session.getDefaultInstance(props, null);
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(this.from));
msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(this.to));
msg.setSubject(this.subject);
msg.setText(this.body);
msg.setSentDate(new Date());
Transport.send(msg);


ERROR 2007-01-26 11:14:37,913 (ComplicatedEmail.java:send:125) - javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;
nested exception is:
java.net.ConnectException: Connection refused: connect
javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;
nested exception is:
java.net.ConnectException: Connection refused: connect
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1282)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370)
at javax.mail.Service.connect(Service.java:275)
at javax.mail.Service.connect(Service.java:156)
at javax.mail.Service.connect(Service.java:105)
at javax.mail.Transport.send0(Transport.java:168)
at javax.mail.Transport.send(Transport.java:98)
at com.nuhorizons.rosettanet.www.ComplicatedEmail.send(ComplicatedEmail.java:112)
at com.nuhorizons.rosettanet.util.AlertEmailUtil.sendEmail(AlertEmailUtil.java:265)
at com.nuhorizons.rosettanet.util.AlertEmailUtil.sendDesignEmail(AlertEmailUtil.java:242)
at com.nuhorizons.rosettanet.util.AlertEmailUtil.send5C2SentSuccessfully(AlertEmailUtil.java:148)
at com.nuhorizons.rosettanet.controller.transmit.remote.RemoteRequestRegistrationTransmitter.sendSuccessAlert(RemoteRequestRegistrationTransmitter.java:150)
at com.nuhorizons.rosettanet.controller.transmit.remote.RemoteMessageTransmitter.doPost(RemoteMessageTransmitter.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.jstripe.tomcat.probe.Tomcat55AgentValve.invoke(Tomcat55AgentValve.java:20)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:507)
at java.net.Socket.connect(Socket.java:457)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:232)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1250)
... 30 more
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

This line: "java.net.ConnectException: Connection refused: connect" leads me to believe that the problem might be on the server side. Have you checked the server logs to see if there is anything untoward happening?
 
rajanikanth bhagavan kanth
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm also getting the same error.
Can any one please respond to this mail

Regards,
Bhagavan R
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have an SMTP server running on localhost? If so, check its log files for messages. If not, then that's your problem.
[ December 08, 2008: Message edited by: Ulf Dittmer ]
 
rajanikanth bhagavan kanth
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, in my localhost SMTP server is running sucessfully i didn't get any error messages.But my application gives that error message.

Let me know if im not clear.

Regards,
Bhagavan R
 
L Ganesh
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am also getting the same error
can anyone please help me
i have tried with a different mail client and my ports and server is fine.
 
Varun Padival
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Was there any resolution for this issues. I am also facing the same problem as Matthew.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question is the same:
Do you have an SMTP server running on localhost on port 25? If so, check its log files for messages. If not, then that's your problem.
 
Varun Padival
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have email server on different machine and its running on prot 25.

The problem we are getting is that the mails will be working for some days. After some days suddenly the mails will not be sent and if we check the log we see the error messages as "Could not connect to the mail server : port 25". After we restart the tomcat the emails will start working again.

Are there any configurations/logs where we can check exactly what the problem was

Thanks,
Varun Padival
 
Paul Okeke
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I have a related problem but I was able to solve mine problem half way by eliminating the but still my sent Mail so not yet delivered to the desired destination.
How I solved it:



But my unfortunate thing is that my mail is not delivered after successful sending.
 
Paul Clapham
Sheriff
Posts: 21155
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you know the mail is not delivered? Have you checked the server where you are sending it to?
 
Rob Spoor
Sheriff
Pie
Posts: 20559
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Okeke, please stick to your own thread for this. Don't hijack other people's threads.
 
Paul Okeke
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime, I don't know that it is an offense Posting what I felt will assist Matthew McHale if not solve his situation.
I felt we are all here to help each other, Matthew McHale has almost the same problem as I do.
In my case, I have already gotten some solutions which I felt will help Matthew McHale if not solving his own problem totally.

I post my Apologies.......................
 
Rob Spoor
Sheriff
Pie
Posts: 20559
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matthew hasn't been here since 2007, so I doubt he will read this. But I have misread your post somewhat, so I too apologize for being somewhat harsh.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic