-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphp_sendmail_upload2.php
More file actions
66 lines (59 loc) · 2.75 KB
/
php_sendmail_upload2.php
File metadata and controls
66 lines (59 loc) · 2.75 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
session_start();
include("dbconnect.php");
if (empty($_SESSION['student_email'])) {
header("Location: index.php");
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php include("head.php"); ?>
</head>
<body>
<div id="templatemo_wrapper">
<?php include("header.php"); ?>
<?php include("menu_header.php"); ?>
<div id="templatemo_main_top"></div>
<div id="templatemo_main">
<div style="background-color:#d7d7d7;margin:auto">
<?php
$strTo = $_POST["Email"];
$strSubject = $_POST["txtSubject"];
$strMessage = nl2br($_POST["txtDescription"]);
$strSid = md5(uniqid(time()));
$strHeader = "From: " . $_POST["txtFormName"] . "<" . $_POST["txtFormEmail"] . ">\nReply-To: " . $_POST["txtFormEmail"] . "\nX-Mailer: PHP/" . phpversion() . "\n";
$strHeader .= "MIME-Version: 1.0\n";
$strHeader .= "Content-Type: multipart/mixed; boundary=\"" . $strSid . "\"\n\n";
$strHeader .= "This is a multi-part message in MIME format.\n";
$strHeader .= "--" . $strSid . "\n";
$strHeader .= "Content-type: text/html; charset=utf-8\n";
$strHeader .= "Content-Transfer-Encoding: 7bit\n\n";
$strHeader .= $strMessage . "\n\n";
if ($_FILES["fileAttach"]["name"] != "") {
$strFilesName = $_FILES["fileAttach"]["name"];
$strContent = chunk_split(base64_encode(file_get_contents($_FILES["fileAttach"]["tmp_name"])));
$strHeader .= "--" . $strSid . "\n";
$strHeader .= "Content-Type: application/octet-stream; name=\"" . $strFilesName . "\"\n";
$strHeader .= "Content-Transfer-Encoding: base64\n";
$strHeader .= "Content-Disposition: attachment; filename=\"" . $strFilesName . "\"\n\n";
$strHeader .= $strContent . "\n\n";
}
$flgSend = @mail($strTo, $strSubject, null, $strHeader); // @ = No Show Error //
if ($flgSend) {
echo "Mail sent successfully. Thank you!";
} else {
echo "Sorry! Unable to send mail.";
}
?>
</div>
<div class="cleaner"></div>
<div class="cleaner"></div>
</div> <!-- end of templatemo_main -->
<div id="templatemo_main_bottom"></div>
<?php include("footer.php"); ?> <!-- end of templatemo_footer -->
</div>
<!-- end of wrapper -->
</body>
</html>