473,382 Members | 1,635 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,382 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 3812
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.