Advertisement
Guest User

php mailer

a guest
Mar 31st, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.56 KB | None | 0 0
  1. <?php
  2. require_once("conexion.php");
  3. $conexion = conexion ();
  4. $getpermiso=mysqli_query($conexion,"SELECT * FROM permiso" );
  5. while($row =mysqli_fetch_array($getpermiso)){
  6. $f_vencimiento= $row['f_vencimiento'];
  7. $datetime1 = new DateTime("now");
  8. $datetime2 = date_create($row['f_vencimiento']);
  9. $interval = date_diff($datetime1, $datetime2);
  10. $dias= $interval->format('%a');
  11. echo $dias;
  12. if ($dias==60 || $dias==29 || $dias==0){
  13. require 'PHPMailer/PHPMailerAutoload.php';
  14.  
  15. $mail = new PHPMailer();
  16. //$body = file_get_contents('inicio.php');
  17. $mail->IsSMTP();
  18. $mail->Host = 'smtp.gmail.com';
  19. $mail->SMTPAuth= true;
  20. $mail->Username='';
  21. $mail->Password='';
  22. $mail->Port = 587;
  23. //$mail->SMTPDebug = 2;
  24. $mail->SMTPSecure = 'tls';
  25. $mail->SetFrom('', 'Ender Chacon');
  26. $mail->AddAddress($row['correo'], 'Supervisor');
  27. $mail->AddAddress($row['correo0'], 'Supervisor');
  28. $mail->AddAddress($row['correo1'], 'Supervisor');
  29. $mail->Subject = 'Vencimiento de Permiso Bomberos';
  30. $mail->Body    = '<justify><b>Estimado el sistemas de Permisos de Bomberos Le informa:</b><br>
  31.                 Que el Permiso Numero: '.$row['id'].' de la oficina:'.$row['oficina'].' vence el dia:'.$row['f_vencimiento'].' por favor<br>
  32.                 por la oficina mas cercana con los siguientes requisitos: <br><br><br>
  33.                 1) Cedula de Identidad <br>
  34.                 2) Registro Mercantil <br>
  35.                 3) Registro de Informacion Fiscal <br></justify>';
  36. $mail->AltBody = "Saludos y Gracias Por su atencion";
  37. if(!$mail->Send()) {
  38. echo 'Error : ' . $mail->ErrorInfo;
  39. } else {
  40.     echo 'ENVIADO!!';
  41.   }
  42. }
  43. else {
  44.   echo "no enviado";
  45. }
  46. }
  47.  
  48. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement