No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

contact.php 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. <?php
  2. header("Access-Control-Allow-Origin: *");
  3. // Only process POST reqeusts.
  4. if ($_SERVER["REQUEST_METHOD"] == "POST") {
  5. // Get the form fields and remove whitespace.
  6. $first_name = strip_tags(trim($_POST["name"]));
  7. $first_name = str_replace(array("\r","\n"),array(" "," "),$first_name);
  8. $email = filter_var(trim($_POST["email"]), FILTER_SANITIZE_EMAIL);
  9. $subject = trim($_POST["subject"]);
  10. // $phone = trim($_POST["number"]);
  11. $message = trim($_POST["contactMessage"]);
  12. // Check that data was sent to the mailer.
  13. if ( empty($first_name) OR empty($message) OR !filter_var($email, FILTER_VALIDATE_EMAIL)) {
  14. // Set a 400 (bad request) response code and exit.
  15. http_response_code(400);
  16. echo "Please complete the form and try again.";
  17. exit;
  18. }
  19. // Set the recipient email address.
  20. $recipient = "mailcheck@whizthemes.com";
  21. // Set the email subject.
  22. $subject = "Ketab - Mail From $first_name";
  23. // Build the email content.
  24. $email_content =
  25. '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  26. <html lang="en">
  27. <head>
  28. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  29. <meta name="viewport" content="width=device-width, initial-scale=1">
  30. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  31. <title>Contact Mail</title>
  32. <!--[if (mso)|(mso 16)]>
  33. <style type="text/css">
  34. body, table, td, a, span { font-family: Arial, sans-serif !important; }
  35. a {text-decoration: none !important;}
  36. </style>
  37. <![endif]-->
  38. <style type="text/css">
  39. /* CLIENT-SPECIFIC STYLES */
  40. body,
  41. table,
  42. td,
  43. a {
  44. -webkit-text-size-adjust: 100%;
  45. -ms-text-size-adjust: 100%;
  46. }
  47. table,
  48. td {
  49. mso-table-lspace: 0pt;
  50. mso-table-rspace: 0pt;
  51. }
  52. img {
  53. -ms-interpolation-mode: bicubic;
  54. }
  55. /* RESET STYLES */
  56. img {
  57. border: 0;
  58. outline: none;
  59. text-decoration: none;
  60. }
  61. table {
  62. border-collapse: collapse !important;
  63. }
  64. body {
  65. color: #626160!important;
  66. font-family: Tahoma, Arial, sans-serif !important;
  67. font-size: 14px;
  68. margin: 0 !important;
  69. padding: 0 !important;
  70. width: 100% !important;
  71. }
  72. h1,
  73. h2,
  74. h3,
  75. h4,
  76. h5,
  77. h6,
  78. p,
  79. img {
  80. margin: 0;
  81. padding: 0;
  82. }
  83. /* iOS BLUE LINKS */
  84. a[x-apple-data-detectors] {
  85. color: inherit !important;
  86. text-decoration: none !important;
  87. font-size: inherit !important;
  88. font-family: inherit !important;
  89. font-weight: inherit !important;
  90. line-height: inherit !important;
  91. }
  92. /* ANDROID CENTER FIX */
  93. div[style*="margin: 16px 0;"] {
  94. margin: 0 !important;
  95. }
  96. /* MEDIA QUERIES */
  97. @media all and (max-width:639px) {
  98. .wrapper {
  99. width: 320px!important;
  100. padding: 0 !important;
  101. }
  102. .container {
  103. width: 300px!important;
  104. padding: 0 !important;
  105. }
  106. .mobile {
  107. width: 300px!important;
  108. display: block!important;
  109. padding: 0 !important;
  110. }
  111. .img {
  112. width: 100% !important;
  113. height: auto !important;
  114. }
  115. *[class="mobileOff"] {
  116. width: 0px !important;
  117. display: none !important;
  118. }
  119. *[class*="mobileOn"] {
  120. display: block !important;
  121. max-height: none !important;
  122. }
  123. }
  124. /*===========================
  125. Author Custom Style
  126. ============================*/
  127. hr{
  128. border-color: #fefefe;
  129. border-width: 1px;
  130. margin-bottom: 10px;
  131. }
  132. .message-content{
  133. font-size: 16px;
  134. line-height: 1.6;
  135. }
  136. .content-wrapper h2{
  137. font-weight: 400;
  138. font-size: 20px;
  139. }
  140. .email-txt a{
  141. color: #222222 !important;
  142. text-decoration: none !important;
  143. }
  144. </style>
  145. </head>
  146. <body style="margin:0; padding:0; background-color:#F3F3F3;">
  147. <center>
  148. <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#F2F2F2">
  149. <tr>
  150. <td height="100" style="font-size:10px; line-height:10px;">&nbsp;</td>
  151. </tr>
  152. <tr>
  153. <td align="center" valign="top">
  154. <!--== TemplateContainer Start ==-->
  155. <table width="640" cellpadding="0" cellspacing="0" border="0" class="wrapper" bgcolor="#FFFFFF">
  156. <tr>
  157. <td height="60" style="font-size:10px; line-height:10px;">&nbsp;</td>
  158. </tr>
  159. <!--== Content Area Start ==-->
  160. <tr class="content-wrapper">
  161. <td align="center" valign="top">
  162. <table width="560" cellpadding="0" cellspacing="0" border="0" class="container">
  163. <!--== Start Name Field Item ==-->
  164. <tr>
  165. <td width="100%" class="mobile" align="left" valign="middle">
  166. <h3>Name:</h3>
  167. <hr>
  168. <h2>' . $first_name. '</h2>
  169. </td>
  170. </tr>
  171. <!--== End Name Field Item ==-->
  172. <!--== Start Separator ==-->
  173. <tr>
  174. <td height="30" style="font-size:10px; line-height:10px;">&nbsp;</td>
  175. </tr>
  176. <!--== End Separator ==-->
  177. <!--== Start Email Field Item ==-->
  178. <tr>
  179. <td width="100%" class="mobile" align="left" valign="middle">
  180. <h3>Email:</h3>
  181. <hr>
  182. <h2 class="email-txt">'. $email .'</h2>
  183. </td>
  184. </tr>
  185. <!--== Start Email Field Item ==-->
  186. <!--== Start Separator ==-->
  187. <tr>
  188. <td height="30" style="font-size:10px; line-height:10px;">&nbsp;</td>
  189. </tr>
  190. <!--== End Separator ==-->
  191. <!--== Start Phone Field Item ==-->
  192. // <tr>
  193. // <td width="100%" class="mobile" align="left" valign="middle">
  194. // <h3>Phone or Mobile:</h3>
  195. // <hr>
  196. // <h2>'. $phone .'</h2>
  197. // </td>
  198. // </tr>
  199. <!--== End Phone Field Item ==-->
  200. <!--== Start Separator ==-->
  201. <tr>
  202. <td height="30" style="font-size:10px; line-height:10px;">&nbsp;</td>
  203. </tr>
  204. <!--== End Separator ==-->
  205. <!--== Start Subject Field Item ==-->
  206. <tr>
  207. <td width="100%" class="mobile" align="left" valign="middle">
  208. <h3>Subject:</h3>
  209. <hr>
  210. <h2>'. $subject .'</h2>
  211. </td>
  212. </tr>
  213. <!--== End Subject Field Item ==-->
  214. <!--== Start Separator ==-->
  215. <tr>
  216. <td height="30" style="font-size:10px; line-height:10px;">&nbsp;</td>
  217. </tr>
  218. <!--== End Separator ==-->
  219. <!--== Start Message Field Item ==-->
  220. <tr>
  221. <td width="100%" class="mobile" align="left" valign="middle">
  222. <h3>Message:</h3>
  223. <hr>
  224. <p class="message-content">'. $message .'</p>
  225. </td>
  226. </tr>
  227. <!--== End Message Field Item ==-->
  228. </table>
  229. </td>
  230. </tr>
  231. <!--== Content Area End ==-->
  232. <tr>
  233. <td height="60" style="font-size:10px; line-height:10px;">&nbsp;</td>
  234. </tr>
  235. </table>
  236. <!--== TemplateContainer End ==-->
  237. </td>
  238. </tr>
  239. <tr>
  240. <td height="20" style="font-size:10px; line-height:10px;">&nbsp;</td>
  241. </tr>
  242. <tr>
  243. <td align="center" valign="top">
  244. <a href="https://hasthemes.com/" target="_blank"><img width="120" src="https://hasthemes.com/wp-content/uploads/2019/01/1.png" alt="HasThemes"></a>
  245. </td>
  246. </tr>
  247. <tr>
  248. <td height="100" style="font-size:10px; line-height:10px;">&nbsp;</td>
  249. </tr>
  250. </table>
  251. </center>
  252. </body>
  253. </html>';
  254. // Build the email headers.
  255. $email_headers = "MIME-Version: 1.0" . "\r\n";
  256. $email_headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
  257. $email_headers .= 'From:' . $first_name . ' ' . 'noreply@yourdomain.com' . "\r\n";
  258. $email_headers .= 'Reply-To:' . $email . "\r\n";
  259. // Send the email.
  260. if (mail($recipient, $subject, $email_content, $email_headers)) {
  261. // Set a 200 (okay) response code.
  262. http_response_code(200);
  263. echo "Thank You! Your message has been sent.";
  264. } else {
  265. // Set a 500 (internal server error) response code.
  266. http_response_code(500);
  267. echo "Oops! Something went wrong and we couldn't send your message.";
  268. }
  269. } else {
  270. // Not a POST request, set a 403 (forbidden) response code.
  271. http_response_code(403);
  272. echo "There was a problem with your submission, please try again.";
  273. }
  274. ?>