Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Define email variables
- $fromEmail = "info@thebistro.co.nz";
- $fromName = "The Bistro";
- $adminEmail = "cy@kombimedia.nz";
- $adminName = "Cy Messenger";
- $userEmail = ($_POST['bookingEmail']);
- $userName = ($_POST['bookingName']);
- $userPhone = ($_POST['bookingPhone']);
- // Convert date format for better readability
- $bookingDate = $_POST['bookingDate'];
- $date = strtotime($bookingDate);
- $bookingDate = date("D d M", $date);
- $bookingNumbers = $_POST['bookingNumbers'];
- // Convert time format for better readability
- $bookingTime = $_POST['bookingTime'];
- $time = strtotime($bookingTime);
- $bookingTime = date("g:i a", $time);
- $userMessage = ($_POST['bookingMessage']);
- // Import PHPMailer classes into the global namespace
- use PHPMailer\PHPMailer\PHPMailer;
- require '../../vendor/autoload.php';
- // Create a new PHPMailer instance
- $mail = new PHPMailer;
- // Tell PHPMailer to use SMTP
- $mail->isSMTP();
- $mail->SMTPDebug = 0;
- $mail->Debugoutput = 'html';
- // SMTP configuration the mail server
- $mail->Host = 'smtp.gmail.com';
- $mail->Port = 587;
- $mail->SMTPSecure = 'tls';
- $mail->SMTPAuth = true;
- // User settings to use for SMTP authentication
- $mail->Username = "thebistrowebmail@gmail.com";
- $mail->Password = '!7$[]7Q2"m!p';
- // Set who the message is to be sent from
- $mail->setFrom($fromEmail, $fromName);
- // Set an alternative reply-to address
- $mail->addReplyTo($userEmail, $userName);
- // Set who the message is to be sent to
- $mail->addAddress($adminEmail, $adminName);
- // Set the subject line
- $mail->Subject = "Booking inquiry from " . $userName . " via the book a table form";
- // Read an HTML message body from an external file, convert referenced images to embedded,
- // convert HTML into a basic plain-text alternative body
- // $mail->msgHTML(file_get_contents('contents.html'), __DIR__);
- $mail->Body = "
- <p><b>Name: </b>" . $userName . "</p>
- <p><b>Phone: </b>" . $userPhone . "</p>
- <p><b>Email: </b>" . $userEmail . "</p>
- <p><b>Dining Date: </b>" . $bookingDate . "</p>
- <p><b>Pax: </b>" . $bookingNumbers . "</p>
- <p><b>Dining Time: </b>" . $bookingTime . "</p>
- <p>" . $userMessage . "</p>";
- // Replace the plain text body with one created manually
- $mail->AltBody = "
- <p><b>Name: </b>" . $userName . "</p>
- <p><b>Phone: </b>" . $userPhone . "</p>
- <p><b>Email: </b>" . $userEmail . "</p>
- <p><b>Dining Date: </b>" . $bookingDate . "</p>
- <p><b>Pax: </b>" . $bookingNumbers . "</p>
- <p><b>Dining Time: </b>" . $bookingTime . "</p>
- <p>" . $userMessage . "</p>";
- // Send the message, check for errors and print error/success messages
- if (!$mail->send()) {
- $_SESSION["bookingDBError"] = "<div class='parsley-errors-list php-val text-center'><p>Something went wrong, your booking form wasn't sent.. " . $mail->ErrorInfo . ".</p><p>Please contact The Bistro at info@thebistro.nz and quote this error message</p></div>";
- } else {
- $_SESSION['bookingSuccess'] = "<div class='success-message mt-4'>Thank you for your booking " . $firstname . "! Please note this is not a confirmed booking. We will come back to you to confirm availability ASAP.</div>";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement