Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $boundary = uniqid();
- $headers = "Mime-Version: 1.0\r\n";
- $headers .= "From: noreply@" . $_SERVER['HTTP_HOST'] . "\r\n";
- $headers .= "Reply-To: =?UTF-8?B?" . base64_encode($_POST['name']) . "?= <" . $_POST['email'] . ">\r\n";
- $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 .= $_POST['message'];
- if (isset($_FILES['attachment'])) {
- $body .= "\r\n";
- for ($i = 0, $c = count($_FILES['attachment']['name']); $i < $c; ++$i) {
- $body .= "--$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";
- }
- $body .= "--$boundary--";
- }
- mail($to, '=?UTF-8?B?' . base64_encode($_POST['subject']) . '?=', $body, $headers);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment