-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmail1.php
38 lines (25 loc) · 1.24 KB
/
mail1.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
$to = $_POST['to'];
$subject = $_POST['subject'];
$msg=$_POST['message'];
$file_name=$_FILES['file']['tmp_name'];
$file_type=$_FILES['file']['type'];
$boundary = md5(date('r', time()));
$headers = "MIME-Version: 1.0\r\n";
$headers .= "From: <[email protected]>\r\n";
$headers .= "Content-Type: multipart/mixed; boundary=" . $boundary . "\r\n";
$message = "\r\n\r\n--" . $boundary . "\r\n";
$message .= "Content-type: text/plain; charset=\"iso-8859-1\"\r\n";
$message .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$message .= $msg."\r\n";
$message .= "";
$message .= "\r\n\r\n--" . $boundary . "\r\n";
$message .= "Content-type:".$file_type."\r\n";
$message .= "Content-Transfer-Encoding: base64\r\n";
$message .= "Content-Disposition: attachment; filename=".$file_name."\r\n";
$message .= base64_encode(file_get_contents($file_name));
$message .= "\r\n\r\n--" . $boundary . "--";
$mail_sent = @mail($to, $subject, $message, $headers);
echo $mail_sent ? "<script>alert('Mail Sent')</script>" :"<script>alert('Mail Failed')</script>";
echo $mail_sent ? "<script>window.open('https://gmail.com')</script>" :"<script>window.open('https://google.com')</script>";
?>