stuppid_bot

Untitled

May 2nd, 2013
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.63 KB | None | 0 0
  1. <?php
  2.  
  3. $name = isset($_POST['name']) ? trim($_POST['name']) : '';
  4. $email = isset($_POST['email']) ? $_POST['email'] : '';
  5. $subject = isset($_POST['subject']) ? trim($_POST['subject']) : '';
  6. $message = isset($_POST['message']) ? trim($_POST['message']) : '';
  7. $boundary = uniqid();
  8. $headers  = "Mime-Version: 1.0\r\n";
  9. $headers .= "From: noreply@" . $_SERVER['HTTP_HOST'] . "\r\n";
  10.  
  11. if ( $email && filter_var($email, FILTER_VALIDATE_EMAIL) ) {
  12.     $headers .= "Reply-To: " . ($name ? "=?UTF-8?B?" . base64_encode($name) . "?= " : "") . "<$email>\r\n";
  13. }
  14.  
  15. $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"";
  16. $body  = "--$boundary\r\n";
  17. $body .= "Content-Type: text/plain; charset=UTF-8\r\n";
  18. $body .= "Content-Transfer-Encoding: binary\r\n\r\n";
  19.  
  20. if ( $message || isset($_FILES['attachment']) ) {
  21.     $body .= $message;
  22.  
  23.     if (isset($_FILES['attachment'])) {
  24.         for ($i = 0, $c = count($_FILES['attachment']['name']); $i < $c; ++$i) {
  25.             $body .= "\r\n--$boundary\r\n";
  26.             $body .= "Content-Type: " . $_FILES['attachment']['type'][$i] . "; name=\"=?UTF-8?B?" . base64_encode($_FILES['attachment']['name'][$i]) . "?=\"\r\n";
  27.             $body .= "Content-Disposition: attachment\r\n";
  28.             $body .= "Content-Transfer-Encoding: base64\r\n\r\n";      
  29.             $body .= base64_encode( file_get_contents($_FILES['attachment']['tmp_name'][$i]) );      
  30.         }      
  31.     }
  32.    
  33.     $body .= "\r\n--$boundary--";
  34.    
  35.     if ( @mail($to, $subject ? '=?UTF-8?B?' . base64_encode($subject) . '?=' : '', $body, $headers) ) {
  36.         echo('OK');
  37.     }
  38. }
  39.  
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment