Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use PHPMailer\PHPMailer\PHPMailer;
- use PHPMailer\PHPMailer\Exception;
- require ('phpmailer/vendor/autoload.php');
- require ('functions/connect_database.php');
- global $pdo;
- //date_default_timezone_set("Europe/Warsaw");
- //$lastday_current_month_date = date('Y-m-t');
- $sql = "SELECT *
- from sms_prices p
- join sms_students s on s.id=p.student_id
- join sms_users u on u.id=s.user_id
- where p.to_pay>p.payed
- ";
- $result = $pdo->prepare($sql);
- $result->execute();
- //$users_data = $result->fetch();
- //$stmt->execute();
- while($row = $result->fetch())
- {
- $to_pay = $row['to_pay'];
- $to_date = $row['to_date'];
- $payed = $row['payed'];
- $period = $row['period'];
- $email = $row['email'];
- $mail = new PHPMailer(true);
- try {
- //Server settings
- $mail->SMTPDebug = 2;
- $mail->isSMTP();
- $mail->Host = 'smtp.zenbox.pl';
- $mail->Mailer = "smtp";
- $mail->SMTPAuth = true;
- $mail->Username = 'adreswysylki';
- $mail->Password = 'hasło';
- $mail->Port = 587;
- $mail->SMTPSecure = 'tls';
- //Recipients
- $mail->setFrom('adreswysylki', 'Soart');
- $mail->AddAddress($email);
- // Content
- $mail->isHTML(true);
- $mail->Subject = 'Przypomnienie o płatności';
- $mail->Body = 'Witamy'
- $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
- $mail->send();
- echo 'Message has been sent';
- } catch (Exception $e) {
- echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement