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

Reply

Join Date: Oct 2008
Posts: 3
Reputation: dwdish is an unknown quantity at this point 
Solved Threads: 0
dwdish dwdish is offline Offline
Newbie Poster

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

 
0
  #1
Oct 22nd, 2008
Hi, my jsp page uses sun.net.smtp.SmtpClient to send email. It worked fine until the hosted location was moved to another server. Now it generates the sun.net.smtp.SmtpProtocolException 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 "mail.xxx.com" 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.

Thanks

The following is the code responsible for the email: (error follows)
-------------------------------------------------------------
  1. try
  2. {
  3. client = new SmtpClient(localhost);
  4. client.from(EMAIL_FROM);
  5. client.to(strEmail);
  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. }
  14. catch(IOException e)
  15. {
  16. <div><%=e%></div>
  17. }
Exceptions
-----------------------------------------------------------

sun.net.smtp.SmtpProtocolException:
at sun.net.smtp.SmtpClient.issueCommand(SmtpClient.ja va:48)
at sun.net.smtp.SmtpClient.closeServer(SmtpClient.jav a:38)
at sun.net.NetworkClient.openServer(NetworkClient.jav a:117)
at sun.net.smtp.SmtpClient.openServer(SmtpClient.java :111)
at sun.net.smtp.SmtpClient.(SmtpClient.java:156)
at org.apache.jsp.dbg.email_005fpass2_jsp._jspService (email_005fpass2_jsp.java:134)
at org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:133)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:856)
at org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:311)
at org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:301)
at org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:248)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:856)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:284)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:204)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:564)
at org.apache.catalina.core.StandardContextValve.invo keInternal(StandardContextValve.java:245)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:199)
at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:151)
at org.apache.catalina.authenticator.AuthenticatorBas e.invoke(AuthenticatorBase.java:509)
at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:149)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:564)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:195)
at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:151)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:164)
at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:149)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:564)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:156)
at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:564)
at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:972)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(Co yoteAdapter.java:211)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyo teHandler.java:309)
at org.apache.jk.common.HandlerRequest.invoke(Handler Request.java:387)
at org.apache.jk.common.ChannelSocket.invoke(ChannelS ocket.java:673)
at org.apache.jk.common.ChannelSocket.processConnecti on(ChannelSocket.java:615)
at org.apache.jk.common.SocketConnection.runIt(Channe lSocket.java:786)
at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:677)
at java.lang.Thread.run(Thread.java:536)
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,160
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 137
dickersonka dickersonka is offline Offline
Veteran Poster

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

 
0
  #2
Oct 23rd, 2008
most likely, this is a security issue then, and you will need to authenticate with the server to be able to send mail to other domains
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,160
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 137
dickersonka dickersonka is offline Offline
Veteran Poster

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

 
0
  #3
Oct 23rd, 2008
And also, since it is on another server, make sure to use its mail.xxx.xxx address. Normally mail servers, will require you to authenticate to send mail from a machine other than itself.
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 3
Reputation: dwdish is an unknown quantity at this point 
Solved Threads: 0
dwdish dwdish is offline Offline
Newbie Poster

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

 
0
  #4
Oct 25th, 2008
Thanks, since the issue is not solved I turned to re-write the code in JavaMail. I found the following lines on web and it works. The only problem is that it can't send in non-ascii characters like Chinese. For detail, please read my latest message. Thank you very much.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,160
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 137
dickersonka dickersonka is offline Offline
Veteran Poster

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

 
0
  #5
Oct 25th, 2008
What lines?
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC