Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. if ($_GET['accion'] == 'invitar'){
  2.  
  3. $idReunion_fk = $_GET['idReunion_fk'];
  4.  
  5. $idEmpleado_fk = $_GET['idEmpleado_fk'];
  6.  
  7. $empleado_reunionDao = new Empleado_reunion_DAO();
  8.  
  9. $nexo = new Empleado_reunion();
  10.  
  11. $nexo->setIdReunion_fk($idReunion_fk);
  12. $nexo->setIdEmpleado_fk($idEmpleado_fk);
  13. $nexo->setConfirmacion(0);
  14.  
  15. $empleado_reunionDao->insertarNexo($nexo);
  16.  
  17. //Tras haber insertado el registro, comienzo con el envío del mail.
  18. require_once '../model/empleadoDAO.php';
  19.  
  20. $empleadoDAO = new EmpleadoDAO();
  21.  
  22. require_once '../model/empleadoModelo.php';
  23.  
  24. $para = new Empleado();
  25.  
  26. //Aquí obtengo el empleado al que quiero mandar el mail
  27. $para = $empleadoDAO->obtenerEmpleado($idEmpleado_fk );
  28.  
  29. //Aquí obtengo su mail
  30. $para = $para->getEmail();
  31.  
  32. $asunto = "asunto del mensaje";
  33.  
  34. $mensaje = "<a href='/views/empleados_asistentes.php?".$idReunion_fk."'>aceptar invitación</a>";
  35.  
  36. //aquí ejecuto mi función
  37. enviaMail($para, $asunto, $mensaje);
  38.  
  39. }
  40.  
  41. include_once('class.phpmailer.php');
  42.  
  43. function enviaMail($para, $asuntoMensaje, $mensaje)
  44. {
  45.  
  46. $mail = new PHPMailer();
  47. $mail->IsSMTP(); // enviar vÌa SMTP
  48. $mail->Host = 'mail.gmail.com';
  49. $mail->SMTPAuth = true; // activar la identificacÌn SMTP
  50. $mail->Username = 'correo@gmail.com'; // usuario SMTP
  51. $mail->Password = 'contrasena'; // clave SMTP
  52. $mail->From = "correo@gmail.com"; //remitente
  53. $mail->FromName = "Sistema de administración de reuniones";//nombre de remitente
  54. //$mail->AddReplyTo(AppEmailSoporte); //e-mail para respuestas
  55. $mail->Port = 465;
  56. $mail->SMTPSecure = "ssl";
  57. $mail->CharSet = 'UTF-8';
  58. //Destinatarios
  59. $mail->AddAddress($para); //destinatario
  60.  
  61. // Establecemos los par·metros del mensaje: ancho y formato.
  62. $mail->WordWrap = 50; // ancho del mensaje
  63. $mail->IsHTML(true); // enviar como HTML
  64.  
  65. $mail->Subject = $asuntoMensaje; //Asunto
  66.  
  67. $mail->Body = $mensaje; //Cuerpo
  68. //$mail->AltBody = $Mensaje; //Cabecera
  69.  
  70. // AÒadimos los adjuntos al mensaje
  71. // $mail->AddAttachment("./Manifiestos/".$nombreFichero .".txt"); // podemos aÒadir un adjunto directamente
  72.  
  73. if ($mail->Send()){
  74. //bien
  75. }else{
  76. //mal
  77. }
  78.  
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement