Advertisement
Guest User

Untitled

a guest
Oct 10th, 2017
490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.86 KB | None | 0 0
  1. <?php
  2. use PHPMailer\PHPMailer\PHPMailer;
  3. use PHPMailer\PHPMailer\Exception;
  4. require 'vendor/autoload.php';
  5.  
  6.  
  7. $name = $_POST['name'];
  8. $priority = $_POST['priority'];
  9. $message = $_POST['message'];
  10. $email = $_POST['email'];
  11. $product = $_POST['product'];
  12. $type = $_POST['type'];
  13. $phone = $_POST['phone'];
  14.  
  15. if ($type == '') {
  16. $type = 'N/A';
  17. }
  18.  
  19. $mail = new PHPMailer;
  20. $mail->isSMTP();
  21. //Enable SMTP debugging
  22. $mail->SMTPDebug = 2;
  23. //Set the hostname of the mail server
  24. $mail->Host = 'smtp.gmail.com';
  25. //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
  26. $mail->Port = 587;
  27. //Set the encryption system to use - ssl (deprecated) or tls
  28. $mail->SMTPSecure = 'tls';
  29. //Whether to use SMTP authentication
  30. $mail->SMTPAuth = true;
  31. //Username to use for SMTP authentication - use full email address for gmail
  32. $mail->Username = "vwardak@gmail.com";
  33. //Password to use for SMTP authentication
  34. $mail->Password = "REMOVED";
  35. //Set who the message is to be sent from
  36. $mail->setFrom($email, $name);
  37. //Set who the message is to be sent to
  38. $mail->addAddress('vwardak@gmail.com', 'HBPlug');
  39. //Content
  40. $mail->isHTML(true); // Set email format to HTML
  41. $mail->Subject = 'Contact Form - '.$project_name;
  42. $mail->Body = '
  43. <table border="0" cellpadding="0" cellspacing="0" width="100%" style="
  44. max-width: 35%;
  45. margin: 0 auto;
  46. background: white;
  47. text-align:center;
  48. ">
  49. <tr>
  50. <td>
  51. <table border="0" cellpadding="0" cellspacing="0" width="100%" style="
  52. padding: 25px;
  53. background: #fff;
  54. border: 1px solid #ddd;
  55. border-top: none !important;
  56. text-align: center;">
  57. <tr>
  58. <td>
  59. <table border="0" cellpadding="0" cellspacing="0" width="100%">
  60. <tr>
  61. <td style="
  62. font-size: 18px;
  63. padding-bottom: 5px;
  64. ">
  65. Customer Name
  66. </td>
  67. </tr>
  68. <tr>
  69. <td style="
  70. font-size: 15px;
  71. color: #adadad;
  72. ">
  73. '. $name .'
  74. </td>
  75. </tr>
  76. </table>
  77. </td>
  78. </tr>
  79. </table>
  80. </td>
  81. </tr>
  82. <tr>
  83. <td>
  84. <table border="0" cellpadding="0" cellspacing="0" width="100%" style="
  85. padding: 25px;
  86. background: #fff;
  87. border: 1px solid #ddd;
  88. border-top: none !important;
  89. text-align: center;">
  90. <tr>
  91. <td>
  92. <table border="0" cellpadding="0" cellspacing="0" width="100%">
  93. <tr>
  94. <td style="
  95. font-size: 18px;
  96. padding-bottom: 5px;
  97. ">
  98. Phone Number
  99. </td>
  100. </tr>
  101. <tr>
  102. <td style="
  103. font-size: 15px;
  104. color: #adadad;
  105. ">
  106. '. $phone .'
  107. </td>
  108. </tr>
  109. </table>
  110. </td>
  111. </tr>
  112. </table>
  113. </td>
  114. </tr>
  115. <tr>
  116. <td>
  117. <table border="0" cellpadding="0" cellspacing="0" width="100%" style="
  118. padding: 25px;
  119. background: #fff;
  120. border: 1px solid #ddd;
  121. border-top: none !important;
  122. text-align: center;">
  123. <tr>
  124. <td>
  125. <table border="0" cellpadding="0" cellspacing="0" width="100%">
  126. <tr>
  127. <td style="
  128. font-size: 18px;
  129. padding-bottom: 5px;
  130. ">
  131. Product
  132. </td>
  133. </tr>
  134. <tr>
  135. <td style="
  136. font-size: 15px;
  137. color: #adadad;
  138. ">
  139. '. $product .' / '. $type .'
  140. </td>
  141. </tr>
  142. </table>
  143. </td>
  144. </tr>
  145. </table>
  146. </td>
  147. </tr>
  148. <tr>
  149. <td>
  150. <table border="0" cellpadding="0" cellspacing="0" width="100%" style="
  151. padding: 25px;
  152. background: #fff;
  153. border: 1px solid #ddd;
  154. border-top: none !important;
  155. text-align: center;">
  156. <tr>
  157. <td>
  158. <table border="0" cellpadding="0" cellspacing="0" width="100%">
  159. <tr>
  160. <td style="
  161. font-size: 18px;
  162. padding-bottom: 5px;
  163. ">
  164. Message
  165. </td>
  166. </tr>
  167. <tr>
  168. <td style="
  169. font-size: 15px;
  170. color: #adadad;
  171. ">
  172. '. $message .'
  173. </td>
  174. </tr>
  175. </table>
  176. </td>
  177. </tr>
  178. </table>
  179. </td>
  180. </tr>
  181. </table>
  182. ';
  183. $response = $_POST["g-recaptcha-response"];
  184. $url = 'https://www.google.com/recaptcha/api/siteverify';
  185. $data = array(
  186. 'secret' => '6LccjzIUAAAAAE-nT0zWpiagBMswsi2VzK5PdKwd',
  187. 'response' => $_POST["g-recaptcha-response"]
  188. );
  189. $options = array(
  190. 'http' => array (
  191. 'method' => 'POST',
  192. 'content' => http_build_query($data)
  193. )
  194. );
  195. $context = stream_context_create($options);
  196. $verify = file_get_contents($url, false, $context);
  197. $captcha_success=json_decode($verify);
  198. if ($captcha_success->success==false) {
  199. header("Location: /");
  200. } else if ($captcha_success->success==true) {
  201. if (!$mail->send()) {
  202. // Error
  203. header("Location: /");
  204. } else {
  205. $mail->send();
  206. header("Location: /");
  207. }
  208. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement