Funcionalidad del mail personalizado iniciado

parent 3bd0957d
package com.roshka.proyectofinal.Postulante;
import com.roshka.proyectofinal.SendMail;
import com.roshka.proyectofinal.entity.Postulante;
import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;
......@@ -7,6 +8,8 @@ import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import javax.mail.MessagingException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
......@@ -21,12 +24,27 @@ public class Filtros extends HttpServlet {
List<Postulante> postulantes = listarPostulante();
String respuesta = req.getParameter("id");
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");
if(respuesta != null) {
System.out.println(valor);
System.out.println(respuesta);
update(Integer.parseInt(req.getParameter("id")), valor);
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){
postulantes = buscarPorNombre(nombre);
}
......
package com.roshka.proyectofinal;
import com.roshka.proyectofinal.bootcamp.BootcampDao;
import com.roshka.proyectofinal.entity.Bootcamp;
import java.util.Properties;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
......@@ -22,24 +25,29 @@ 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
BootcampDao bootcampDao = new BootcampDao();
Bootcamp bootcamp = bootcampDao.getBootcampById(bootcampId);
String correo = "nahuelmereles1@gmail.com";
String contra = "ozydnpynyoqsowjn";
String correoDestino = postulanteCorreoDestino;
Properties properties = new Properties();
properties.put("mail.smtp.host","smtp.gmail.com");
properties.setProperty("mail.smtp.starttls.enable","true");
properties.put("mail.smtp.ssl.trust","smtp.gmail.com");
properties.setProperty("mail.smtp.port","587");
properties.setProperty("mail.smtp,user",correo);
properties.setProperty("mail.smtp.auth","true");
properties.put("mail.smtp.host","smtp.gmail.com");
properties.setProperty("mail.smtp.starttls.enable","true");
properties.put("mail.smtp.ssl.trust","smtp.gmail.com");
properties.setProperty("mail.smtp.port","587");
properties.setProperty("mail.smtp,user",correo);
properties.setProperty("mail.smtp.auth","true");
Session s = Session.getDefaultInstance(properties);
MimeMessage mensaje = new MimeMessage(s);
mensaje.setFrom(new InternetAddress(correo));
mensaje.addRecipient(Message.RecipientType.TO, new InternetAddress(correoDestino));
mensaje.setSubject("Hola que tal soy yo");
mensaje.setText("Ya funciona?");
mensaje.setSubject("Confirmacion al Bootcamp de " + bootcamp.getTitulo()); // Asunto del correo
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.connect(correo, contra);
......
......@@ -119,10 +119,6 @@
<form action="filtros-postulante" method="get">
<input type="hidden" name="valor" value="0">
<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>
</form>
</c:when>
......@@ -130,6 +126,12 @@
<form action="filtros-postulante" method="get">
<input type="hidden" name="valor" value="1">
<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>
</form>
</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