Advertisement
Guest User

Untitled

a guest
Dec 12th, 2017
611
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.04 KB | None | 0 0
  1. <?php
  2. // Define email variables
  3. $fromEmail = "info@thebistro.co.nz";
  4. $fromName = "The Bistro";
  5. $adminEmail = "cy@kombimedia.nz";
  6. $adminName = "Cy Messenger";
  7. $userEmail = ($_POST['bookingEmail']);
  8. $userName = ($_POST['bookingName']);
  9. $userPhone = ($_POST['bookingPhone']);
  10. // Convert date format for better readability
  11. $bookingDate = $_POST['bookingDate'];
  12. $date = strtotime($bookingDate);
  13. $bookingDate = date("D d M", $date);
  14. $bookingNumbers = $_POST['bookingNumbers'];
  15. // Convert time format for better readability
  16. $bookingTime = $_POST['bookingTime'];
  17. $time = strtotime($bookingTime);
  18. $bookingTime = date("g:i a", $time);
  19. $userMessage = ($_POST['bookingMessage']);
  20. // Import PHPMailer classes into the global namespace
  21. use PHPMailer\PHPMailer\PHPMailer;
  22. require '../../vendor/autoload.php';
  23. // Create a new PHPMailer instance
  24. $mail = new PHPMailer;
  25. // Tell PHPMailer to use SMTP
  26. $mail->isSMTP();
  27. $mail->SMTPDebug = 0;
  28. $mail->Debugoutput = 'html';
  29. // SMTP configuration the mail server
  30. $mail->Host = 'smtp.gmail.com';
  31. $mail->Port = 587;
  32. $mail->SMTPSecure = 'tls';
  33. $mail->SMTPAuth = true;
  34. // User settings to use for SMTP authentication
  35. $mail->Username = "thebistrowebmail@gmail.com";
  36. $mail->Password = '!7$[]7Q2"m!p';
  37. // Set who the message is to be sent from
  38. $mail->setFrom($fromEmail, $fromName);
  39. // Set an alternative reply-to address
  40. $mail->addReplyTo($userEmail, $userName);
  41. // Set who the message is to be sent to
  42. $mail->addAddress($adminEmail, $adminName);
  43. // Set the subject line
  44. $mail->Subject = "Booking inquiry from " . $userName . " via the book a table form";
  45. // Read an HTML message body from an external file, convert referenced images to embedded,
  46. // convert HTML into a basic plain-text alternative body
  47. // $mail->msgHTML(file_get_contents('contents.html'), __DIR__);
  48. $mail->Body = "
  49. <p><b>Name: </b>" . $userName . "</p>
  50. <p><b>Phone: </b>" . $userPhone . "</p>
  51. <p><b>Email: </b>" . $userEmail . "</p>
  52. <p><b>Dining Date: </b>" . $bookingDate . "</p>
  53. <p><b>Pax: </b>" . $bookingNumbers . "</p>
  54. <p><b>Dining Time: </b>" . $bookingTime . "</p>
  55. <p>" . $userMessage . "</p>";
  56. // Replace the plain text body with one created manually
  57. $mail->AltBody = "
  58. <p><b>Name: </b>" . $userName . "</p>
  59. <p><b>Phone: </b>" . $userPhone . "</p>
  60. <p><b>Email: </b>" . $userEmail . "</p>
  61. <p><b>Dining Date: </b>" . $bookingDate . "</p>
  62. <p><b>Pax: </b>" . $bookingNumbers . "</p>
  63. <p><b>Dining Time: </b>" . $bookingTime . "</p>
  64. <p>" . $userMessage . "</p>";
  65. // Send the message, check for errors and print error/success messages
  66. if (!$mail->send()) {
  67.   $_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>";
  68. } else {
  69.     $_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>";
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement