By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,426 Members | 1,718 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,426 IT Pros & Developers. It's quick & easy.

Help, Please!!! Can't Send Mail with SmtpClient

P: 1
Hi, my jsp page uses to send email. It worked fine until the hosted location was moved to another server. Now it generates the and the hosting company can't find what's wrong with it so I'm here hoping somebody can help.

The hosting company tried sending email from the server and it was okay and found no restrictions that prevents my page to access the smtp server.

What could cause the SmtpProtocolException? "locahost" was what I used to connect to the smtp server. When it failed, I tried another smtp server like "" for another domain and it worked but the problem is that this server can't let me send mail to other domains except its own domain.


The following is the code responsible for the email: (error follows)
Expand|Select|Wrap|Line Numbers
  1. try
  2. {
  3. client = new SmtpClient(localhost);
  4. client.from(EMAIL_FROM);
  6. PrintStream message = client.startMessage();
  7. message.println("From: " + EMAIL_FROM);
  8. message.println("To: " + strEmail);
  9. message.println("Subject: " + SUBJECT);
  10. message.println();
  11. ...
  12. client.closeServer(); 
  13. catch(IOException e)
  14. {
  15. <div><%=e%></div>
  16. }
Expand|Select|Wrap|Line Numbers
  2. at va:48) 
  3. at a:38) 
  4. at a:117) 
  5. at :111) 
  6. at 
  7. at org.apache.jsp.dbg.email_005fpass2_jsp._jspService ( 
  8. at org.apache.jasper.runtime.HttpJspBase.service(Http 
  9. at javax.servlet.http.HttpServlet.service(HttpServlet .java:856) 
  10. at org.apache.jasper.servlet.JspServletWrapper.servic e( 
  11. at org.apache.jasper.servlet.JspServlet.serviceJspFil e( 
  12. at org.apache.jasper.servlet.JspServlet.service(JspSe 
  13. at javax.servlet.http.HttpServlet.service(HttpServlet .java:856) 
  14. at ternalDoFilter( 
  15. at Filter( 
  16. at org.apache.catalina.core.StandardWrapperValve.invo ke( 
  17. at org.apache.catalina.core.StandardValveContext.invo keNext( 
  18. at org.apache.catalina.core.StandardPipeline.invoke(S 
  19. at org.apache.catalina.core.StandardContextValve.invo keInternal( 
  20. at org.apache.catalina.core.StandardContextValve.invo ke( 
  21. at org.apache.catalina.core.StandardValveContext.invo keNext( 
  22. at org.apache.catalina.authenticator.AuthenticatorBas e.invoke( 
  23. at org.apache.catalina.core.StandardValveContext.invo keNext( 
  24. at org.apache.catalina.core.StandardPipeline.invoke(S 
  25. at org.apache.catalina.core.StandardHostValve.invoke( 
  26. at org.apache.catalina.core.StandardValveContext.invo keNext( 
  27. at org.apache.catalina.valves.ErrorReportValve.invoke ( 
  28. at org.apache.catalina.core.StandardValveContext.invo keNext( 
  29. at org.apache.catalina.core.StandardPipeline.invoke(S 
  30. at org.apache.catalina.core.StandardEngineValve.invok e( 
  31. at org.apache.catalina.core.StandardValveContext.invo keNext( 
  32. at org.apache.catalina.core.StandardPipeline.invoke(S 
  33. at org.apache.catalina.core.ContainerBase.invoke(Cont 
  34. at org.apache.coyote.tomcat5.CoyoteAdapter.service(Co 
  35. at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyo 
  36. at org.apache.jk.common.HandlerRequest.invoke(Handler 
  37. at org.apache.jk.common.ChannelSocket.invoke(ChannelS 
  38. at org.apache.jk.common.ChannelSocket.processConnecti on( 
  39. at org.apache.jk.common.SocketConnection.runIt(Channe 
  40. at org.apache.tomcat.util.threads.ThreadPool$ControlR 
  41. at
Oct 22 '08 #1
Share this Question
Share on Google+
2 Replies

P: 39
post the whole tomcat log. mainly the line "caused by" for ur exception. most likely u r failing to authenticate or some firewall issues
Oct 22 '08 #2

Expert 2.5K+
P: 3,112
post the whole tomcat log. mainly the line "caused by" for ur exception.
Please use [CODE] ... [/code] tags when posting it - it's not strictly required when posting a textfile, but it clearly shows, what belongs together. Also, please certainly use them when posting code. We do require it in that case. I've added CODE tags to your post above.

Nepomuk (Moderator)
Oct 22 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.