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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • btcoder
    New Member
    • Oct 2008
    • 1

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

    Hi, my jsp page uses sun.net.smtp.Sm tpClient to send email. It worked fine until the hosted location was moved to another server. Now it generates the sun.net.smtp.Sm tpProtocolExcep tion 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 SmtpProtocolExc eption? "locahost" was what I used to connect to the smtp server. When it failed, I tried another smtp server like "mail.xxx.c om" 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)
    -------------------------------------------------------------
    [code=java]try
    {
    client = new SmtpClient(loca lhost);
    client.from(EMA IL_FROM);
    client.to(strEm ail);
    PrintStream message = client.startMes sage();
    message.println ("From: " + EMAIL_FROM);
    message.println ("To: " + strEmail);
    message.println ("Subject: " + SUBJECT);
    message.println ();
    ...
    client.closeSer ver();
    }
    catch(IOExcepti on e)
    {
    <div><%=e%></div>
    }[/code]

    Exceptions
    -----------------------------------------------------------
    Code:
    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)
    ---------------------------------------------------------------------
    Last edited by Nepomuk; Oct 22 '08, 09:47 PM. Reason: Please use [CODE] tags
  • N002213F
    New Member
    • Sep 2007
    • 38

    #2
    post the whole tomcat log. mainly the line "caused by" for ur exception. most likely u r failing to authenticate or some firewall issues

    Comment

    • Nepomuk
      Recognized Expert Specialist
      • Aug 2007
      • 3111

      #3
      Originally posted by N002213F
      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.

      Greetings,
      Nepomuk (Moderator)

      Comment

      Working...