fixed mailer class

This commit is contained in:
2026-09-04 10:03:38 +02:00
parent 83af2e2d17
commit b8957a8a24
15 changed files with 479 additions and 631 deletions
+73 -84
View File
@@ -1,14 +1,12 @@
<?php
header('Content-Type: text/html; charset=utf-8');
include('Connections/bkngstm.php');
require_once __DIR__ . '/class/mailer.php';
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
?>
<?php
header('Content-Type: text/html; charset=utf-8');
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
include('Connections/bkngstm.php');
$conn = new mysqli($servername, $username, $password, $dbname);
$conn = $bkngstm;
?>
<?php
// teacher notification
@@ -26,30 +24,25 @@ $sql = "SELECT serviceschedule.dateschedule, serviceschedule.dateschedule, servi
$result = $conn->query($sql);
//send email to teacher
require 'phpmailer/src/Exception.php';
require 'phpmailer/src/PHPMailer.php';
require 'phpmailer/src/SMTP.php';
//send email to teacher
//mail to client
//mail to client
$mail = new PHPMailer(true);
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'mail.yogasoul.it'; // Specify main and backup server
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'info@yogasoul.it'; // SMTP username
$mail->Password = '!Testolina88'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
$mail->Port = '587';
$mail->isSMTP();
$mail->Host = $_ENV['MAIL_HOST'];
$mail->SMTPAuth = true;
$mail->Username = $_ENV['MAIL_USERNAME'];
$mail->Password = $_ENV['MAIL_PASSWORD'];
$mail->SMTPSecure = $_ENV['MAIL_ENCRYPTION'];
$mail->Port = (int) $_ENV['MAIL_PORT'];
$mail->CharSet = 'UTF-8';
//mail sent
//mail sent
$messageedit=" <p style='font-size: 14px; line-height: 190%;'><span style='font-size: 18px; line-height: 34.2px;'><strong><span style='line-height: 34.2px; font-size: 18px;'> Ciao Aurora , </span></strong></span></p>
$messageedit = " <p style='font-size: 14px; line-height: 190%;'><span style='font-size: 18px; line-height: 34.2px;'><strong><span style='line-height: 34.2px; font-size: 18px;'> Ciao Aurora , </span></strong></span></p>
<p style='font-size: 14px; line-height: 190%;'><span style='font-size: 16px; line-height: 30.4px;'>Di seguito riepilogo delle tue lezioni di domani $nextDay</span></p>";
if ($result->num_rows > 0) {
// Ci sono record, inizializza la variabile $buttonedit
@@ -65,7 +58,7 @@ if ($result->num_rows > 0) {
FROM bookingclass
LEFT JOIN auth_users ON bookingclass.iduser = auth_users.id
WHERE bookingclass.idserviceschedule = '$idserviceschedule'";
$participantResult = $conn->query($participantQuery);
if ($participantResult->num_rows > 0) {
@@ -78,40 +71,37 @@ if ($result->num_rows > 0) {
$buttonedit .= "</tr>";
}
$buttonedit .= "</table>";
// Conta il numero di partecipanti
$numPartecipanti = $participantResult->num_rows;
// Aggiungi l'ultima riga con il numero di posti e maxcapacity
$buttonedit .= "<em>Partecipanti: $numPartecipanti / " . $row["maxcapacity"] . "</em><br><br>";
$buttonedit .= "<em>Partecipanti: $numPartecipanti / " . $row["maxcapacity"] . "</em><br><br>";
} else {
// Nessun partecipante trovato
$buttonedit .= "Nessun partecipante per questa classe.";
}
}
include('mail/emailtemplate2.php');
// Email body content
//$trfnmbmail=$appformn.'r'.$revnumb;
$htmlContent = $mailmessage1;
$mail->From = 'info@yogasoul.it';
$mail->FromName = 'YogiBook [YogaSoul]';
$mail->addAddress('info@yogasoul.it'); // Add a recipient
include('mail/emailtemplate2.php');
// Email body content
//$trfnmbmail=$appformn.'r'.$revnumb;
$htmlContent = $mailmessage1;
$mail->Subject = "YogiBook - Lezioni di domani $nextDay";
$mail->Body = $htmlContent;
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
$mail->From = $_ENV['MAIL_FROM_ADDRESS'];
$mail->FromName = $_ENV['MAIL_FROM_NAME'];
$mail->addAddress('info@yogasoul.it'); // riepilogo alla teacher
$mail->Subject = "YogiBook - Lezioni di domani $nextDay";
$mail->Body = $htmlContent;
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
} else {
// Nessun record trovato
$buttonedit = "Non ci sono record per il giorno successivo.";
@@ -119,14 +109,13 @@ $mail->send();
// Chiudi la connessione al database
$conn->close();
// Connessione $bkngstm condivisa: non la chiudiamo qui
?>
<?php
// email notification to users
$conn = new mysqli($servername, $username, $password, $dbname);
$conn = $bkngstm;
// Calcolo della data successiva
$today = date("Y-m-d");
@@ -148,56 +137,57 @@ $result = $conn->query($sql);
if ($result->num_rows > 0) {
// Stampa dei risultati
while ($row = $result->fetch_assoc()) {
$servicename = $row["servicename"];
$servicename = $row["servicename"];
$formatted_date = $row["formatted_date"];
$first_name = $row["first_name"];
$email = $row["email"];
//send email to users
//send email to users
//mail to client
$mail = new PHPMailer(true);
//mail to client
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'premium60.web-hosting.com'; // Specify main and backup server
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'info@yogasoul.it'; // SMTP username
$mail->Password = '!Testolina88'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
$mail->Port = '587';
$mail = new PHPMailer(true);
$messageedit=" <p style='font-size: 14px; line-height: 190%;'><span style='font-size: 18px; line-height: 34.2px;'><strong><span style='line-height: 34.2px; font-size: 18px;'> Ciao $first_name , </span></strong></span></p>
$mail->isSMTP();
$mail->Host = $_ENV['MAIL_HOST'];
$mail->SMTPAuth = true;
$mail->Username = $_ENV['MAIL_USERNAME'];
$mail->Password = $_ENV['MAIL_PASSWORD'];
$mail->SMTPSecure = $_ENV['MAIL_ENCRYPTION'];
$mail->Port = (int) $_ENV['MAIL_PORT'];
$mail->CharSet = 'UTF-8';
$messageedit = " <p style='font-size: 14px; line-height: 190%;'><span style='font-size: 18px; line-height: 34.2px;'><strong><span style='line-height: 34.2px; font-size: 18px;'> Ciao $first_name , </span></strong></span></p>
<p style='font-size: 14px; line-height: 190%;'><span style='font-size: 16px; line-height: 30.4px;'>Eccoti un promemoria per ricordarti la tua prossima lezione di '$servicename' del $formatted_date .</span></p>";
$buttonedit="<a href='https://yogibook.yogasoul.it/' target='_blank' class='v-button v-font-size' style='box-sizing: border-box;display: inline-block;text-decoration: none;-webkit-text-size-adjust: none;text-align: center;color: #FFFFFF; background-color: #3AAEE0; border-radius: 4px;-webkit-border-radius: 4px; -moz-border-radius: 4px; width:auto; max-width:100%; overflow-wrap: break-word; word-break: break-word; word-wrap:break-word; mso-border-alt: none;font-size: 14px;'>
$buttonedit = "<a href='https://yogibook.yogasoul.it/' target='_blank' class='v-button v-font-size' style='box-sizing: border-box;display: inline-block;text-decoration: none;-webkit-text-size-adjust: none;text-align: center;color: #FFFFFF; background-color: #3AAEE0; border-radius: 4px;-webkit-border-radius: 4px; -moz-border-radius: 4px; width:auto; max-width:100%; overflow-wrap: break-word; word-break: break-word; word-wrap:break-word; mso-border-alt: none;font-size: 14px;'>
<span style='display:block;padding:10px 20px;line-height:120%;'><span style='line-height: 16.8px;'>YogiBook - YogaSoul</span></span>
</a>";
include('mail/emailtemplate2.php');
// Email body content
include('mail/emailtemplate2.php');
// Email body content
//$trfnmbmail=$appformn.'r'.$revnumb;
$htmlContent = $mailmessage1;
$mail->From = 'info@yogasoul.it';
$mail->FromName = 'YogiBook [YogaSoul]';
$mail->addAddress($email); // Add a recipient
//$trfnmbmail=$appformn.'r'.$revnumb;
$htmlContent = $mailmessage1;
$mail->Subject = "YogiBook - Promemoria lezione di domani $nextDay";
$mail->Body = $htmlContent;
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->From = $_ENV['MAIL_FROM_ADDRESS'];
$mail->FromName = $_ENV['MAIL_FROM_NAME'];
$mail->addAddress($email); // promemoria all'utente
$mail->Subject = "YogiBook - Promemoria lezione di domani $nextDay";
$mail->Body = $htmlContent;
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
$mail->send();
echo "Nome evento: " . $servicename . "<br>";
echo "Data e ora: " . $formatted_date . "<br>";
echo "Nome allievo: " . $first_name . "<br>";
@@ -207,7 +197,6 @@ $mail->send();
echo "Nessun risultato trovato.";
}
$conn->close();
?>