Advertisement
bvlad05

Untitled

Jun 19th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.78 KB | None | 0 0
  1. <?php
  2. $method = $_SERVER['REQUEST_METHOD'];
  3. //Script Foreach
  4. $c = true;
  5. if ( $method === 'POST' ) {
  6.     $site_name = trim($_POST["site_name"]);
  7.     $admin_email  = trim($_POST["admin_email"]);
  8.     $admin_email_replay = trim($_POST["admin_email_replay"]);
  9.     $form_subject = trim($_POST["form_subject"]);
  10.     foreach ( $_POST as $key => $value ) {
  11.         if ( $value != "" && $key != "site_name" && $key != "admin_email" && $key != "form_subject" ) {
  12.             $message .= "
  13.             " . ( ($c = !$c) ? '<tr>':'<tr style="background-color: #f8f8f8;">' ) . "
  14.                 <td style='padding: 10px; border: #e9e9e9 1px solid;'><b>$key</b></td>
  15.                 <td style='padding: 10px; border: #e9e9e9 1px solid;'>$value</td>
  16.             </tr>
  17.             ";
  18.         }
  19.     }
  20. } else if ( $method === 'GET' ) {
  21.     $site_name = trim($_GET["site_name"]);
  22.     $admin_email  = trim($_GET["admin_email"]);
  23.     $admin_email_replay = trim($_GET["admin_email_replay"]);
  24.     $form_subject = trim($_GET["form_subject"]);
  25.     foreach ( $_GET as $key => $value ) {
  26.         if ( $value != "" && $key != "site_name" && $key != "admin_email" && $key != "form_subject" ) {
  27.             $message .= "
  28.             " . ( ($c = !$c) ? '<tr>':'<tr style="background-color: #f8f8f8;">' ) . "
  29.                 <td style='padding: 10px; border: #e9e9e9 1px solid;'><b>$key</b></td>
  30.                 <td style='padding: 10px; border: #e9e9e9 1px solid;'>$value</td>
  31.             </tr>
  32.             ";
  33.         }
  34.     }
  35. }
  36. $message = "<table style='width: 100%;'>$message</table>";
  37. function adopt($text) {
  38.     return '=?UTF-8?B?'.Base64_encode($text).'?=';
  39. }
  40. $headers = "MIME-Version: 1.0" . PHP_EOL .
  41. "Content-Type: text/html; charset=utf-8" . PHP_EOL .
  42. 'From: '.adopt($site_name).' <'.$admin_email.'>' . PHP_EOL .
  43. // 'Reply-To: '.$admin_email.'' . PHP_EOL;
  44. 'Reply-To: '.$admin_email.','.$admin_email_replay.'' . PHP_EOL;
  45. mail($admin_email, adopt($form_subject), $message, $headers );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement