Funcionalidad del mail personalizado iniciado

parent 3bd0957d
package com.roshka.proyectofinal.Postulante; package com.roshka.proyectofinal.Postulante;
import com.roshka.proyectofinal.SendMail;
import com.roshka.proyectofinal.entity.Postulante; import com.roshka.proyectofinal.entity.Postulante;
import jakarta.servlet.RequestDispatcher; import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException; import jakarta.servlet.ServletException;
...@@ -7,6 +8,8 @@ import jakarta.servlet.annotation.WebServlet; ...@@ -7,6 +8,8 @@ import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import javax.mail.MessagingException;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -21,12 +24,27 @@ public class Filtros extends HttpServlet { ...@@ -21,12 +24,27 @@ public class Filtros extends HttpServlet {
List<Postulante> postulantes = listarPostulante(); List<Postulante> postulantes = listarPostulante();
String respuesta = req.getParameter("id"); String respuesta = req.getParameter("id");
String valor = req.getParameter("valor"); String valor = req.getParameter("valor");
String nombre_postulante = req.getParameter("nombre");
String apellido_postulante = req.getParameter("apellido");
String correo_postulante = req.getParameter("correo");
int bootcamp_id = Integer.parseInt(req.getParameter("bootcamp_id"));
String nombre = req.getParameter("nombreBuscar")== null ? "0" : req.getParameter("nombreBuscar"); String nombre = req.getParameter("nombreBuscar")== null ? "0" : req.getParameter("nombreBuscar");
if(respuesta != null) { if(respuesta != null) {
System.out.println(valor); System.out.println(valor);
System.out.println(respuesta); System.out.println(respuesta);
update(Integer.parseInt(req.getParameter("id")), valor); update(Integer.parseInt(req.getParameter("id")), valor);
postulantes = listarPostulante(); postulantes = listarPostulante();
try {
SendMail send = new SendMail();
send.sendingMail(correo_postulante, nombre_postulante, apellido_postulante, bootcamp_id);
// Averiguar que recibo con el SOUT sobretodo en bootcamp_id, una vez que pueda tener el
// login.
// Para obtener el login necesito poder iniciar sesion en Usuario
// Una vez iniciado sesion se prueba cambiando el estado de 'RECHAZADO' a 'Aceptado'
System.out.println(correo_postulante+nombre_postulante+apellido_postulante+ bootcamp_id);
} catch (MessagingException e) {
throw new RuntimeException(e);
}
} else if(nombre.length() > 1){ } else if(nombre.length() > 1){
postulantes = buscarPorNombre(nombre); postulantes = buscarPorNombre(nombre);
} }
......
package com.roshka.proyectofinal; package com.roshka.proyectofinal;
import com.roshka.proyectofinal.bootcamp.BootcampDao;
import com.roshka.proyectofinal.entity.Bootcamp;
import java.util.Properties; import java.util.Properties;
import javax.activation.DataHandler; import javax.activation.DataHandler;
import javax.activation.FileDataSource; import javax.activation.FileDataSource;
...@@ -22,8 +25,13 @@ public class SendMail { ...@@ -22,8 +25,13 @@ public class SendMail {
} }
public void meetingMail(String postulanteCorreoDestino) throws AddressException, MessagingException {
public void sendingMail(String postulanteCorreoDestino, String nombre, String apellido, int bootcampId) throws AddressException, MessagingException {
// emanuel.lugo01@gmail.com // emanuel.lugo01@gmail.com
BootcampDao bootcampDao = new BootcampDao();
Bootcamp bootcamp = bootcampDao.getBootcampById(bootcampId);
String correo = "nahuelmereles1@gmail.com"; String correo = "nahuelmereles1@gmail.com";
String contra = "ozydnpynyoqsowjn"; String contra = "ozydnpynyoqsowjn";
String correoDestino = postulanteCorreoDestino; String correoDestino = postulanteCorreoDestino;
...@@ -38,8 +46,8 @@ public class SendMail { ...@@ -38,8 +46,8 @@ public class SendMail {
MimeMessage mensaje = new MimeMessage(s); MimeMessage mensaje = new MimeMessage(s);
mensaje.setFrom(new InternetAddress(correo)); mensaje.setFrom(new InternetAddress(correo));
mensaje.addRecipient(Message.RecipientType.TO, new InternetAddress(correoDestino)); mensaje.addRecipient(Message.RecipientType.TO, new InternetAddress(correoDestino));
mensaje.setSubject("Hola que tal soy yo"); mensaje.setSubject("Confirmacion al Bootcamp de " + bootcamp.getTitulo()); // Asunto del correo
mensaje.setText("Ya funciona?"); mensaje.setText("Hola " + nombre + " " + apellido + ", fuiste aceptado al bootcamp de " + bootcamp.getTitulo() + " que empezara el " + bootcamp.getFecha_inicio() + " y terminara el " + bootcamp.getFecha_fin() + ", muchas felicidades y esperamos verte pronto."); // Mensaje del correo
Transport transport = s.getTransport("smtp"); Transport transport = s.getTransport("smtp");
transport.connect(correo, contra); transport.connect(correo, contra);
......
...@@ -119,10 +119,6 @@ ...@@ -119,10 +119,6 @@
<form action="filtros-postulante" method="get"> <form action="filtros-postulante" method="get">
<input type="hidden" name="valor" value="0"> <input type="hidden" name="valor" value="0">
<input type="hidden" name="id" value="${postulante.id}"> <input type="hidden" name="id" value="${postulante.id}">
<input type="hidden" name="nombre" value="${postulante.nombre}">
<input type="hidden" name="apellido" value="${postulante.apellido}">
<input type="hidden" name="correo" value="${postulante.correo}">
<button type="submit">Rechazar</button> <button type="submit">Rechazar</button>
</form> </form>
</c:when> </c:when>
...@@ -130,6 +126,12 @@ ...@@ -130,6 +126,12 @@
<form action="filtros-postulante" method="get"> <form action="filtros-postulante" method="get">
<input type="hidden" name="valor" value="1"> <input type="hidden" name="valor" value="1">
<input type="hidden" name="id" value="${postulante.id}"> <input type="hidden" name="id" value="${postulante.id}">
<input type="hidden" name="nombre" value="${postulante.nombre}">
<input type="hidden" name="apellido" value="${postulante.apellido}">
<input type="hidden" name="correo" value="${postulante.correo}">
<input type="hidden" name="bootcamp_id" value="${postulante.bootcamp_id}">
<button type="submit">Rechazar</button>
<button type="submit">Aceptado</button> <button type="submit">Aceptado</button>
</form> </form>
</c:otherwise> </c:otherwise>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment