Advertisement
Guest User

Untitled

a guest
Nov 19th, 2018
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.15 KB | None | 0 0
  1. <?php
  2. /*
  3. Name: Contact Form
  4. Written by: Okler Themes - (http://www.okler.net)
  5. Theme Version: 6.0.0
  6. */
  7.  
  8. session_cache_limiter('nocache');
  9. header('Expires: ' . gmdate('r', 0));
  10.  
  11. header('Content-type: application/json');
  12.  
  13. require_once('php-mailer/PHPMailerAutoload.php');
  14.  
  15. // Step 1 - Enter your email address below.
  16. $email = 'info@jagcatering.ca';
  17.  
  18. // If the e-mail is not working, change the debug option to 2 | $debug = 2;
  19. $debug = 0;
  20.  
  21. $subject = $_POST['subject'];
  22.  
  23. $fields = array(
  24. 0 => array(
  25. 'text' => 'name',
  26. 'val' => $_POST['name']
  27. ),
  28. 1 => array(
  29. 'text' => 'contactname',
  30. 'val' => $_POST['contactname']
  31. ),
  32. 2 => array(
  33. 'text' => 'email',
  34. 'val' => $_POST['email']
  35. ),
  36. 3 => array(
  37. 'text' => 'billingaddress',
  38. 'val' => $_POST['billingaddress']
  39. ),
  40. 4 => array(
  41. 'text' => 'deliveryaddress',
  42. 'val' => $_POST['deliveryaddress']
  43. ),
  44. 5 => array(
  45. 'text' => 'deliverytime',
  46. 'val' => $_POST['deliverytime']
  47. ),
  48. 6 => array(
  49. 'text' => 'guestnumbers',
  50. 'val' => $_POST['guestnumbers']
  51. ),
  52. 7 => array(
  53. 'text' => 'itemrequest',
  54. 'val' => $_POST['itemrequest']
  55. ),
  56. 8 => array(
  57. 'text' => 'beverages',
  58. 'val' => $_POST['beverages']
  59. ),
  60. 9 => array(
  61. 'text' => 'message',
  62. 'val' => $_POST['message']
  63. )
  64. );
  65.  
  66. $message = '';
  67.  
  68. foreach($fields as $field) {
  69. $message .= $field['text'].": " . htmlspecialchars($field['val'], ENT_QUOTES) . "<br>\n";
  70. }
  71.  
  72. $mail = new PHPMailer(true);
  73.  
  74. try {
  75.  
  76. $mail->SMTPDebug = $debug; // Debug Mode
  77.  
  78. // Step 2 (Optional) - If you don't receive the email, try to configure the parameters below:
  79.  
  80. $mail->IsSMTP(); // Set mailer to use SMTP
  81. $mail->Host = 'smtpout.secureserver.net'; // Specify main and backup server
  82. $mail->SMTPAuth = true; // Enable SMTP authentication
  83. $mail->Username = 'info@jagcatering.ca'; // SMTP username
  84. $mail->Password = ''; // SMTP password
  85. //$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
  86. $mail->Port = 80; // TCP port to connect to
  87.  
  88. $mail->AddAddress($email); // Add another recipient
  89.  
  90. //$mail->AddAddress('tania@jagcatering.ca', 'Person 2'); // Add a secondary recipient
  91. //$mail->AddCC('person3@domain.com', 'Person 3'); // Add a "Cc" address.
  92. //$mail->AddBCC('person4@domain.com', 'Person 4'); // Add a "Bcc" address.
  93.  
  94. $mail->SetFrom($email, $_POST['name']);
  95. $mail->AddReplyTo($_POST['email'], $_POST['name']);
  96.  
  97. $mail->IsHTML(true); // Set email format to HTML
  98.  
  99. $mail->CharSet = 'UTF-8';
  100.  
  101. $mail->Subject = $subject;
  102. $mail->Body = $message;
  103.  
  104.  
  105. $mail->Send();
  106. $arrResult = array ('response'=>'success');
  107.  
  108. } catch (phpmailerException $e) {
  109. $arrResult = array ('response'=>'error','errorMessage'=>$e->errorMessage());
  110. } catch (Exception $e) {
  111. $arrResult = array ('response'=>'error','errorMessage'=>$e->getMessage());
  112. }
  113.  
  114. if ($debug == 0) {
  115. echo json_encode($arrResult);
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement