Hello all,

I've been trying to email from my struts application without success.
I've first tried the standard approach wich is to use javax.mail.* javax.mail.internet.* classes.
As on O'reilly's Servlet Cookbook.

Then I've tried commons email, also without success.

So at this point I wonder if I need to add something to my classpath within my Tomcat5 which is part of my Fedora core box.

I wonder if I could get some advice on that?

I am having exceptions thrown at SecurityFilter but I haven't done anything to my app as far as security goes as it is very simple
at this point, just a simple work for school.

Any ideas?

Here's a test action from my last attempt:

import org.apache.commons.mail.*;


public class TestAction extends Action {
private void send1Mail(String From, String To, String Subject, String Body) {
       try {
           SimpleEmail email = new SimpleEmail();
           email.setHostName("smtp.mail.br <http://smtp.antunes.eti.br>");
           email.addTo(To);
           email.setFrom(From);
           email.setSubject(Subject);
           email.setMsg(Body);
           email.send();
       }
       catch (EmailException e) {
           getServlet().log("Error Mail : "+e.toString());
       }
}

   public ActionForward execute(
       ActionMapping mapping,
       ActionForm form,
       HttpServletRequest request,
       HttpServletResponse response) throws Exception {

       response.setContentType("text/html");
       PrintWriter out = response.getWriter();
String Subject = "Email test ";
       // message to owner.
       String to = "[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>";
       String body = "Hello nando,\n\n";
send1Mail("[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>",to,Subject,body);
       return null;
   }

javax.servlet.ServletException: Servlet execution threw an exception
        
org.securityfilter.filter.SecurityFilter.doFilter(SecurityFilter.java:188)

*root cause*

java.lang.NoClassDefFoundError: javax/mail/Message
        com.nando.struts.action.TestAction.send1Mail(TestAction.java:35)
        com.nando.struts.action.TestAction.execute(TestAction.java:69)





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to