Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL);
- session_start();
- if ( isset($_POST['captcha']) && strtolower( trim($_POST['captcha']) ) == $_SESSION['captcha'] && ( $message = isset($_POST['message']) ? trim($_POST['message']) : '' || isset($_FILES['attachment']) ) ) {
- $headers = "Mime-Version: 1.0\r\n";
- $headers .= ( $email = isset($_POST['email']) ? $_POST['email'] : '' && filter_var($email, FILTER_VALIDATE_EMAIL) )
- ? "From: " . ( ($name = isset($_POST['name']) ? trim($_POST['name']) : '') ? "=?UTF-8?B?" . base64_encode($name) . "?= " : "" ) . "<$email>\r\n"
- : "From: noreply@" . $_SERVER['HTTP_HOST'] . "\r\n";
- $boundary = md5( time() );
- $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"";
- $body = "--$boundary\r\n";
- $body .= "Content-Type: text/plain; charset=UTF-8\r\n";
- $body .= "Content-Transfer-Encoding: binary\r\n\r\n";
- $body .= $message;
- if (isset($_FILES['attachment'])) {
- for ($i = 0, $c = count($_FILES['attachment']['name']); $i < $c; ++$i) {
- $body .= "\r\n--$boundary\r\n";
- $body .= "Content-Type: " . $_FILES['attachment']['type'][$i] . "; name=\"=?UTF-8?B?" . base64_encode($_FILES['attachment']['name'][$i]) . "?=\"\r\n";
- $body .= "Content-Disposition: attachment\r\n";
- $body .= "Content-Transfer-Encoding: base64\r\n\r\n";
- $body .= base64_encode( file_get_contents($_FILES['attachment']['tmp_name'][$i]) );
- }
- }
- $body .= "\r\n--$boundary--";
- if ( @mail($to, '=?UTF-8?B?' . base64_encode('Отправлено через обратную связь') . '?=', $body, $headers) ) {
- echo('OK');
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment