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