-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend_mail.php
52 lines (45 loc) · 1.08 KB
/
send_mail.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
$webmaster_email = "[email protected]";
$thankyou_page = "thank_you.html";
$error_page = "error_message.html";
$email_address = $_REQUEST['email'];
$user_name = $_REQUEST['name'];
$email_subject = $_REQUEST['subject'];
$email_message = $_REQUEST['message'];
$msg =
"Name: " . $user_name . "\r\n" .
"Email: " . $email_address . "\r\n" .
"Subject: " . $email_subject . "\r\n" .
"Message: " . $email_message ;
function isInjected($str) {
$injections = array('(\n+)',
'(\r+)',
'(\t+)',
'(%0A+)',
'(%0D+)',
'(%08+)',
'(%09+)'
);
$inject = join('|', $injections);
$inject = "/$inject/i";
if(preg_match($inject,$str)) {
return true;
}
else {
return false;
}
}
if (!isset($_REQUEST['email_address'])) {
header( "Location: $thankyou_page" );
}
elseif (empty($user_name) || empty($email_address)) {
header( "Location: $error_page" );
}
elseif ( isInjected($email_address) || isInjected($user_name) || isInjected($email_message) ) {
header( "Location: $error_page" );
}
else {
mail( "$webmaster_email", "Feedback Form Results", $msg );
header( "Location: $thankyou_page" );
}
?>