473,396 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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)
-------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  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. catch(IOException e)
  14. {
  15. <div><%=e%></div>
  16. }
Exceptions
-----------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. sun.net.smtp.SmtpProtocolException: 
  2. at sun.net.smtp.SmtpClient.issueCommand(SmtpClient.ja va:48) 
  3. at sun.net.smtp.SmtpClient.closeServer(SmtpClient.jav a:38) 
  4. at sun.net.NetworkClient.openServer(NetworkClient.jav a:117) 
  5. at sun.net.smtp.SmtpClient.openServer(SmtpClient.java :111) 
  6. at sun.net.smtp.SmtpClient.(SmtpClient.java:156) 
  7. at org.apache.jsp.dbg.email_005fpass2_jsp._jspService (email_005fpass2_jsp.java:134) 
  8. at org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:133) 
  9. at javax.servlet.http.HttpServlet.service(HttpServlet .java:856) 
  10. at org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:311) 
  11. at org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:301) 
  12. at org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:248) 
  13. at javax.servlet.http.HttpServlet.service(HttpServlet .java:856) 
  14. at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:284) 
  15. at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:204) 
  16. at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:256) 
  17. at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:151) 
  18. at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:564) 
  19. at org.apache.catalina.core.StandardContextValve.invo keInternal(StandardContextValve.java:245) 
  20. at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:199) 
  21. at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:151) 
  22. at org.apache.catalina.authenticator.AuthenticatorBas e.invoke(AuthenticatorBase.java:509) 
  23. at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:149) 
  24. at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:564) 
  25. at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:195) 
  26. at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:151) 
  27. at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:164) 
  28. at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:149) 
  29. at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:564) 
  30. at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:156) 
  31. at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:151) 
  32. at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:564) 
  33. at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:972) 
  34. at org.apache.coyote.tomcat5.CoyoteAdapter.service(Co yoteAdapter.java:211) 
  35. at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyo teHandler.java:309) 
  36. at org.apache.jk.common.HandlerRequest.invoke(Handler Request.java:387) 
  37. at org.apache.jk.common.ChannelSocket.invoke(ChannelS ocket.java:673) 
  38. at org.apache.jk.common.ChannelSocket.processConnecti on(ChannelSocket.java:615) 
  39. at org.apache.jk.common.SocketConnection.runIt(Channe lSocket.java:786) 
  40. at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:677) 
  41. at java.lang.Thread.run(Thread.java:536)
  42.  
---------------------------------------------------------------------
Oct 22 '08 #1
2 3813
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
Nepomuk
3,112 Expert 2GB
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)
Oct 22 '08 #3

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

Similar topics

1
by: chalk | last post by:
xp_sendmail has died on our SQL Server, I get error "xp_sendmail: failed with mail error 0x80004005" if I try using it. I believe that the reason that this has happened is because the SQL Server...
6
by: erdem kemer | last post by:
i cant send mail to yahoo mail or hotmail while i can send my other mail accounts (pop3) is it becouse yahoo and hotmail is web-based mail here is the code MailMessage mailMsg = new...
4
by: herbert | last post by:
sendmail in .NET 2.0 is as useless as it was in .NET 1.x I can't find out how to make it work. Not to mention how to write a setup project that tests/installs its requirements correctly. the...
0
by: howardr101 | last post by:
Hi, Have hunted around on the groups and can't find anything, hence. I've tried this against 2 mail servers (mailtraq and hmailserver) and it occus with both. The problems seems to be that...
4
by: | last post by:
Hi all, We are using the Asp.Net SMTP Client to send email via our Exchange 2003 SP2 Server. When trying to send email to a local recipient I am getting the following error:- Server:...
2
by: clevrmnkey | last post by:
I've had nothing but trouble from the System.Net.Mail objects, but I finally need to make them work, and I can't for the life of me see what I'm doing wrong. I pared back my mail transaction to...
1
by: les | last post by:
I'm getting this error "BC30456: 'IsBodyHtml' is not a member of 'System.Net.Mail.SmtpClient'" when trying to submit a form and send email. If I remove the line "MailObj.IsBodyHtml = True" the...
7
by: Rob Dob | last post by:
The following code is giving me a timeout problem., no matter what I do I can't send a piece of mail using .net2.0 System.Net.Mail.SmtpClient via port 465 and using ssl, if however I try using...
2
by: mabubakarpk | last post by:
Hello All, I want to send mail through asp.net to other my company domain e.g yahoo, hotmail etc Code is as below ////Start Code//////// Imports System.Net.Mail Dim MailMessage As...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.