Advertisement
Kwarcek

pho

Sep 26th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. <?php
  2.  
  3. use PHPMailer\PHPMailer\PHPMailer;
  4. use PHPMailer\PHPMailer\Exception;
  5.  
  6. require ('phpmailer/vendor/autoload.php');
  7. require ('functions/connect_database.php');
  8.  
  9. global $pdo;
  10.  
  11. //date_default_timezone_set("Europe/Warsaw");
  12.  
  13. //$lastday_current_month_date = date('Y-m-t');
  14.  
  15. $sql = "SELECT *
  16. from sms_prices p
  17. join sms_students s on s.id=p.student_id
  18. join sms_users u on u.id=s.user_id
  19. where p.to_pay>p.payed
  20. ";
  21.  
  22. $result = $pdo->prepare($sql);
  23. $result->execute();
  24.  
  25. //$users_data = $result->fetch();
  26. //$stmt->execute();
  27.  
  28. while($row = $result->fetch())
  29. {
  30. $to_pay = $row['to_pay'];
  31. $to_date = $row['to_date'];
  32. $payed = $row['payed'];
  33. $period = $row['period'];
  34. $email = $row['email'];
  35.  
  36. $mail = new PHPMailer(true);
  37.  
  38. try {
  39. //Server settings
  40. $mail->SMTPDebug = 2;
  41. $mail->isSMTP();
  42. $mail->Host = 'smtp.zenbox.pl';
  43. $mail->Mailer = "smtp";
  44. $mail->SMTPAuth = true;
  45. $mail->Username = 'adreswysylki';
  46. $mail->Password = 'hasło';
  47. $mail->Port = 587;
  48. $mail->SMTPSecure = 'tls';
  49.  
  50. //Recipients
  51. $mail->setFrom('adreswysylki', 'Soart');
  52. $mail->AddAddress($email);
  53.  
  54. // Content
  55. $mail->isHTML(true);
  56. $mail->Subject = 'Przypomnienie o płatności';
  57. $mail->Body = 'Witamy'
  58. $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  59.  
  60. $mail->send();
  61. echo 'Message has been sent';
  62. } catch (Exception $e) {
  63. echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
  64. }
  65.  
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement