Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2019
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 KB | None | 0 0
  1. <?php
  2. /*
  3. Name: Contact Form
  4. Written by: Okler Themes - (http://www.okler.net)
  5. Version: 4.4.0
  6. */
  7.  
  8. session_cache_limiter('nocache');
  9. header('Expires: ' . gmdate('r', 0));
  10.  
  11. header('Content-type: application/json');
  12.  
  13. // Step 1 - Enter your email address below.
  14. $to = 'leads@mybusinessventure.com';
  15.  
  16. // Step 2 - Enable if the server requires SMTP authentication. (true/false)
  17. $enablePHPMailer = false;
  18.  
  19. $subject = "MBV Referral Program";
  20.  
  21. if(isset($_POST['email'])) {
  22.  
  23. $name = $_POST['name'];
  24. $email = $_POST['email'];
  25.  
  26. $fields = array(
  27. 0 => array(
  28. 'text' => 'Reward',
  29. 'val' => $_POST['referralreward']
  30. ),
  31. 1 => array(
  32. 'text' => 'Rep Name',
  33. 'val' => $_POST['repname']
  34. ),
  35. 2 => array(
  36. 'text' => 'Name',
  37. 'val' => $_POST['name']
  38. ),
  39. 3 => array(
  40. 'text' => 'Email',
  41. 'val' => $_POST['email']
  42. ),
  43. 4 => array(
  44. 'text' => 'Phone',
  45. 'val' => $_POST['phone']
  46. ),
  47. 5 => array(
  48. 'text' => 'State',
  49. 'val' => $_POST['state']
  50. ),
  51. 6 => array(
  52. 'text' => 'Occupation',
  53. 'val' => $_POST['currentoccupation']
  54. ),
  55. 7 => array(
  56. 'text' => 'Call',
  57. 'val' => $_POST['expectingcall']
  58. ),
  59. 8 => array(
  60. 'text' => 'Message',
  61. 'val' => $_POST['message']
  62. )
  63. );
  64.  
  65. $message = "";
  66.  
  67. foreach($fields as $field) {
  68. $message .= $field['text'].": " . htmlspecialchars($field['val'], ENT_QUOTES) . "<br>\n";
  69. }
  70.  
  71. // Simple Mail
  72. if(!$enablePHPMailer) {
  73.  
  74. $headers = '';
  75. $headers .= 'From: ' . $name . ' <' . $email . '>' . "\r\n";
  76. $headers .= "Reply-To: " . $email . "\r\n";
  77. $headers .= "MIME-Version: 1.0\r\n";
  78. $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
  79.  
  80. if (mail($to, $subject, $message, $headers)){
  81. $arrResult = array ('response'=>'success');
  82. } else{
  83. $arrResult = array ('response'=>'error');
  84. }
  85.  
  86. // PHP Mailer Library - Docs: https://github.com/PHPMailer/PHPMailer
  87. } else {
  88.  
  89. include("php-mailer/PHPMailerAutoload.php");
  90.  
  91. $mail = new PHPMailer;
  92.  
  93. $mail->IsSMTP(); // Set mailer to use SMTP
  94. $mail->SMTPDebug = 0; // Debug Mode
  95.  
  96. // Step 3 - If you don't receive the email, try to configure the parameters below:
  97.  
  98. //$mail->Host = 'mail.yourserver.com'; // Specify main and backup server
  99. //$mail->SMTPAuth = true; // Enable SMTP authentication
  100. //$mail->Username = 'username'; // SMTP username
  101. //$mail->Password = 'secret'; // SMTP password
  102. //$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
  103.  
  104. $mail->From = $email;
  105. $mail->FromName = $_POST['name'];
  106. $mail->AddAddress($to); // Add a recipient
  107. $mail->AddReplyTo($email, $name);
  108.  
  109. $mail->IsHTML(true); // Set email format to HTML
  110.  
  111. $mail->CharSet = 'UTF-8';
  112.  
  113. $mail->Subject = $subject;
  114. $mail->Body = $message;
  115.  
  116. if(!$mail->Send()) {
  117. $arrResult = array ('response'=>'error');
  118. }
  119.  
  120. $arrResult = array ('response'=>'success');
  121.  
  122. }
  123.  
  124. echo json_encode($arrResult);
  125.  
  126. } else {
  127.  
  128. $arrResult = array ('response'=>'error');
  129. echo json_encode($arrResult);
  130.  
  131. }
  132. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement