Advertisement
stuppid_bot

Untitled

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