Finotti, usei seu exemplo de email simples para fazer um teste:
<%
import java.net.MalformedURLException;
import java.net.URL;
import org.apache.commons.mail.EmailAttachment;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;
import org.apache.commons.mail.MultiPartEmail;
import org.apache.commons.mail.SimpleEmail;
public class CommonsMail {
public CommonsMail() throws EmailException, MalformedURLException {
enviaEmailSimples();
enviaEmailComAnexo();
enviaEmailFormatoHtml();
}
/**
* envia email simples(somente texto)
* @throws EmailException
*/
public void enviaEmailSimples() throws EmailException {
SimpleEmail email = new SimpleEmail();
email.setHostName("smtp.teste.com.br"); // o servidor SMTP para envio do e-mail
email.addTo("[email removido]", "Marcos"); //destinatário
email.setFrom("[email removido]", "Eu"); // remetente
email.setSubject("Teste -> Email simples"); // assunto do e-mail
email.setMsg("Teste de Email utilizando commons-email"); //conteudo do e-mail
email.setAuthentication("teste", "xxxxx");
email.setSmtpPort(465);
email.setSSL(true);
email.setTLS(true);
email.send();
}
/**
* @param args
* @throws EmailException
* @throws MalformedURLException
*/
public static void main(String[] args) throws EmailException, MalformedURLException {
new CommonsMail();
}
}
Olha só o erro que deu:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 2 in the jsp file: /enviaemail.jsp
Syntax error on token “import”, assert expected
1: <%
2: import java.net.MalformedURLException;
3: import java.net.URL;
4:
5: import org.apache.commons.mail.EmailAttachment;
An error occurred at line: 2 in the jsp file: /enviaemail.jsp
java.net.MalformedURLException cannot be resolved
1: <%
2: import java.net.MalformedURLException;
3: import java.net.URL;
4:
5: import org.apache.commons.mail.EmailAttachment;
An error occurred at line: 3 in the jsp file: /enviaemail.jsp
Syntax error on token “import”, assert expected
1: <%
2: import java.net.MalformedURLException;
3: import java.net.URL;
4:
5: import org.apache.commons.mail.EmailAttachment;
6: import org.apache.commons.mail.EmailException;
An error occurred at line: 3 in the jsp file: /enviaemail.jsp
java.net.URL cannot be resolved
1: <%
2: import java.net.MalformedURLException;
3: import java.net.URL;
4:
5: import org.apache.commons.mail.EmailAttachment;
6: import org.apache.commons.mail.EmailException;
An error occurred at line: 5 in the jsp file: /enviaemail.jsp
Syntax error on token “import”, assert expected
2: import java.net.MalformedURLException;
3: import java.net.URL;
4:
5: import org.apache.commons.mail.EmailAttachment;
6: import org.apache.commons.mail.EmailException;
7: import org.apache.commons.mail.HtmlEmail;
8: import org.apache.commons.mail.MultiPartEmail;
An error occurred at line: 5 in the jsp file: /enviaemail.jsp
org.apache.commons.mail.EmailAttachment cannot be resolved to a type
2: import java.net.MalformedURLException;
3: import java.net.URL;
4:
5: import org.apache.commons.mail.EmailAttachment;
6: import org.apache.commons.mail.EmailException;
7: import org.apache.commons.mail.HtmlEmail;
8: import org.apache.commons.mail.MultiPartEmail;
An error occurred at line: 6 in the jsp file: /enviaemail.jsp
Syntax error on token “import”, assert expected
3: import java.net.URL;
4:
5: import org.apache.commons.mail.EmailAttachment;
6: import org.apache.commons.mail.EmailException;
7: import org.apache.commons.mail.HtmlEmail;
8: import org.apache.commons.mail.MultiPartEmail;
9: import org.apache.commons.mail.SimpleEmail;
An error occurred at line: 6 in the jsp file: /enviaemail.jsp
org.apache.commons.mail.EmailException cannot be resolved to a type
3: import java.net.URL;
4:
5: import org.apache.commons.mail.EmailAttachment;
6: import org.apache.commons.mail.EmailException;
7: import org.apache.commons.mail.HtmlEmail;
8: import org.apache.commons.mail.MultiPartEmail;
9: import org.apache.commons.mail.SimpleEmail;
An error occurred at line: 7 in the jsp file: /enviaemail.jsp
Syntax error on token “import”, assert expected
4:
5: import org.apache.commons.mail.EmailAttachment;
6: import org.apache.commons.mail.EmailException;
7: import org.apache.commons.mail.HtmlEmail;
8: import org.apache.commons.mail.MultiPartEmail;
9: import org.apache.commons.mail.SimpleEmail;
10:
An error occurred at line: 7 in the jsp file: /enviaemail.jsp
org.apache.commons.mail.HtmlEmail cannot be resolved to a type
4:
5: import org.apache.commons.mail.EmailAttachment;
6: import org.apache.commons.mail.EmailException;
7: import org.apache.commons.mail.HtmlEmail;
8: import org.apache.commons.mail.MultiPartEmail;
9: import org.apache.commons.mail.SimpleEmail;
10:
An error occurred at line: 8 in the jsp file: /enviaemail.jsp
Syntax error on token “import”, assert expected
5: import org.apache.commons.mail.EmailAttachment;
6: import org.apache.commons.mail.EmailException;
7: import org.apache.commons.mail.HtmlEmail;
8: import org.apache.commons.mail.MultiPartEmail;
9: import org.apache.commons.mail.SimpleEmail;
10:
11: public class CommonsMail {
An error occurred at line: 8 in the jsp file: /enviaemail.jsp
org.apache.commons.mail.MultiPartEmail cannot be resolved to a type
5: import org.apache.commons.mail.EmailAttachment;
6: import org.apache.commons.mail.EmailException;
7: import org.apache.commons.mail.HtmlEmail;
8: import org.apache.commons.mail.MultiPartEmail;
9: import org.apache.commons.mail.SimpleEmail;
10:
11: public class CommonsMail {
An error occurred at line: 9 in the jsp file: /enviaemail.jsp
Syntax error on token “import”, assert expected
6: import org.apache.commons.mail.EmailException;
7: import org.apache.commons.mail.HtmlEmail;
8: import org.apache.commons.mail.MultiPartEmail;
9: import org.apache.commons.mail.SimpleEmail;
10:
11: public class CommonsMail {
12:
An error occurred at line: 9 in the jsp file: /enviaemail.jsp
org.apache.commons.mail.SimpleEmail cannot be resolved to a type
6: import org.apache.commons.mail.EmailException;
7: import org.apache.commons.mail.HtmlEmail;
8: import org.apache.commons.mail.MultiPartEmail;
9: import org.apache.commons.mail.SimpleEmail;
10:
11: public class CommonsMail {
12:
An error occurred at line: 11 in the jsp file: /enviaemail.jsp
Illegal modifier for the local class CommonsMail; only abstract or final is permitted
8: import org.apache.commons.mail.MultiPartEmail;
9: import org.apache.commons.mail.SimpleEmail;
10:
11: public class CommonsMail {
12:
13: public CommonsMail() throws EmailException, MalformedURLException {
14: enviaEmailSimples();
An error occurred at line: 13 in the jsp file: /enviaemail.jsp
EmailException cannot be resolved to a type
10:
11: public class CommonsMail {
12:
13: public CommonsMail() throws EmailException, MalformedURLException {
14: enviaEmailSimples();
15: enviaEmailComAnexo();
16: enviaEmailFormatoHtml();
An error occurred at line: 13 in the jsp file: /enviaemail.jsp
MalformedURLException cannot be resolved to a type
10:
11: public class CommonsMail {
12:
13: public CommonsMail() throws EmailException, MalformedURLException {
14: enviaEmailSimples();
15: enviaEmailComAnexo();
16: enviaEmailFormatoHtml();
An error occurred at line: 15 in the jsp file: /enviaemail.jsp
The method enviaEmailComAnexo() is undefined for the type CommonsMail
12:
13: public CommonsMail() throws EmailException, MalformedURLException {
14: enviaEmailSimples();
15: enviaEmailComAnexo();
16: enviaEmailFormatoHtml();
17: }
18:
An error occurred at line: 16 in the jsp file: /enviaemail.jsp
The method enviaEmailFormatoHtml() is undefined for the type CommonsMail
13: public CommonsMail() throws EmailException, MalformedURLException {
14: enviaEmailSimples();
15: enviaEmailComAnexo();
16: enviaEmailFormatoHtml();
17: }
18:
19: /**
An error occurred at line: 23 in the jsp file: /enviaemail.jsp
EmailException cannot be resolved to a type
20: * envia email simples(somente texto)
21: * @throws EmailException
22: */
23: public void enviaEmailSimples() throws EmailException {
24:
25: SimpleEmail email = new SimpleEmail();
26: email.setHostName(“smtp.multibras.com.br”); // o servidor SMTP para envio do e-mail
An error occurred at line: 25 in the jsp file: /enviaemail.jsp
SimpleEmail cannot be resolved to a type
22: */
23: public void enviaEmailSimples() throws EmailException {
24:
25: SimpleEmail email = new SimpleEmail();
26: email.setHostName(“smtp.multibras.com.br”); // o servidor SMTP para envio do e-mail
27: email.addTo(<a>"[email removido]</a>", “Marcos”); //destinatário
28: email.setFrom(<a>"[email removido]</a>", “Eu”); // remetente
An error occurred at line: 25 in the jsp file: /enviaemail.jsp
SimpleEmail cannot be resolved to a type
22: */
23: public void enviaEmailSimples() throws EmailException {
24:
25: SimpleEmail email = new SimpleEmail();
26: email.setHostName(“smtp.multibras.com.br”); // o servidor SMTP para envio do e-mail
27: email.addTo(<a>"[email removido]</a>", “Marcos”); //destinatário
28: email.setFrom(<a>"[email removido]</a>", “Eu”); // remetente
An error occurred at line: 42 in the jsp file: /enviaemail.jsp
The method main cannot be declared static; static methods can only be declared in a static or top level type
39: * @throws EmailException
40: * @throws MalformedURLException
41: */
42: public static void main(String[] args) throws EmailException, MalformedURLException {
43: new CommonsMail();
44: }
45:
An error occurred at line: 42 in the jsp file: /enviaemail.jsp
EmailException cannot be resolved to a type
39: * @throws EmailException
40: * @throws MalformedURLException
41: */
42: public static void main(String[] args) throws EmailException, MalformedURLException {
43: new CommonsMail();
44: }
45:
An error occurred at line: 42 in the jsp file: /enviaemail.jsp
MalformedURLException cannot be resolved to a type
39: * @throws EmailException
40: * @throws MalformedURLException
41: */
42: public static void main(String[] args) throws EmailException, MalformedURLException {
43: new CommonsMail();
44: }
45:
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.20 logs.