-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend.php
77 lines (67 loc) · 1.84 KB
/
send.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$error = "";
$errorMessage = 'Sorry your message can not be sent.';
//Validate first
if(empty($name)||empty($email)||empty($message))
{
echo "Name and email and message are required !";
header('Location: index.html');
}
//validate against any email injection attempts
if(IsInjected($email))
{
echo "Bad email value!";
header('Location: index.html');
}
$msg = " Name : $name \r\n";
$msg .= " Email: $email \r\n";
$msg .= " WebSite: $website \r\n";
$msg .= " Subject: $subject \r\n";
$msg .= " Message : ".stripslashes($_POST['message'])."\r\n\n";
$msg .= "User information \r\n";
$msg .= "User IP : ".$_SERVER["REMOTE_ADDR"]."\r\n";
$msg .= "Browser info : ".$_SERVER["HTTP_USER_AGENT"]."\r\n";
$msg .= "User come from : ".$_SERVER["SERVER_NAME"]."\r\n";
$msg .= "Template Name : SPLIT VCARD";
$recipient = "support@mutationmedia.net";// Change the recipient email adress to your adrees
$sujet = "Sender information";
$mailheaders = "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n";
if (!$error){
$sending = mail($recipient, $sujet, $msg, $mailheaders);
if ($sending) {
// If the message is sent we output a string to use it
echo "SENDING";
} else {
// Display Error Message
echo $errorMessage;
}
} else {
echo $error; // Display Error Message
}
// Function to validate against any email injection attempts
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;
}
}
?>