correo_old.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. // include it
  3. use PHPMailer\PHPMailer\PHPMailer;
  4. use PHPMailer\PHPMailer\Exception;
  5. require_once('../include/phpmailer6/PHPMailer.php');
  6. require_once('../include/phpmailer6/SMTP.php');
  7. require_once('../include/phpmailer6/Exception.php');
  8. include_once('../include/xTemplate/xtemplate.class.php'); // including mpdf.php
  9. if(!isset($_GET["correo"])){
  10. echo "Debes especificar la dirección a la que se enviará el correo <strong>?correo=</strong>";
  11. exit();
  12. }
  13. $xtpl = new XTemplate('../tpl/nombramiento.tpl.html');
  14. $xtpl->parse("main");
  15. $correo = $_GET["correo"];
  16. $msgInfo = $xtpl->text("main");
  17. //$msgInfo = "<h1>Esto es una prueba</h1><p>El correo se envió atutomáticamente, no debes hacer nada más.</p>";
  18. $mail = new PHPMailer(true);
  19. $mail->IsSMTP();
  20. $mail->SMTPAuth = true;
  21. $mail->Host = "smtp.office365.com";
  22. $mail->Port = 587; // or 587
  23. $mail->SMTPSecure = 'tls'; // if Port is 587
  24. $mail->Username = "alejandro.lara@lasallistas.org.mx";
  25. $mail->Password = "";
  26. // Typical mail data
  27. $mail->AddAddress($correo);
  28. $mail->SetFrom("alejandro.lara@lasallistas.org.mx", "Yo");
  29. $mail->Subject = "Add Your Subject";
  30. $mail->Body = "This is the HTML message body For <b>Setting up PHPMailer with Office365 SMTP using php</b>";
  31. $mail->AltBody = "This is the with out HTML message For Setting up PHPMailer with Office365 using SMTP";
  32. try
  33. {
  34. $mail->Send();
  35. echo "Setting up PHPMailer with Office365 SMTP using php Success!";
  36. }
  37. catch(Exception $exception)
  38. {
  39. echo "<pre>";
  40. var_dump($exception);
  41. echo "</pre>";
  42. //Something went bad
  43. echo "PHPMailer with Office365 Fail :: " . $mail->ErrorInfo;
  44. }
  45. ?>