<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="Teste" method="POST" >
<table>
<tr>
<td><label for="nome">Nome</label></td>
<td><input name="nome" type=text size="33"
maxlength="1000"></td>
</tr>
<tr>
<td><label for="email">e-mail</label></td>
<td><input name="email" type=text size="33"
maxlength="1000"></td>
</tr>
<tr>
<td><input name="submit" type="submit"
value="Enviar" class="botao"></td>
</tr>
</table>
</form>
</body>
</html>
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Teste extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String a = request.getParameter("nome");
String b = request.getParameter("email");
System.out.println(a);
SimpleEmail email = new SimpleEmail();
try {
email.setDebug(true);
email.setHostName("smtp.gmail.com");
email.setAuthentication("*****","*******");
email.setSmtpPort(465);
email.setSSL(true);
email.addTo("[email removido]");
email.setFrom("[email removido]");
email.setSubject("Teste");
email.setMsg(a);
email.setMsg(b);
email.send();
} catch (EmailException e) {
System.out.println(e.getMessage());
}
}
}
O q q esta errado??
Mt obrigado :D
