forked from brikkho-net/brikkho-net.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontact-send.php
59 lines (48 loc) · 1.4 KB
/
contact-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
<?php
define("WEBMASTER_EMAIL", $_POST['sendto']);
if (WEBMASTER_EMAIL == '' || WEBMASTER_EMAIL == 'Testemail') {
die('<div class="alert alert-confirm"> <h6><strong>The recipient email is not correct</strong></h6></div>');
}
define("EMAIL_SUBJECT", $_POST['subject']);
if (EMAIL_SUBJECT == '' || EMAIL_SUBJECT == 'Subject') {
define("EMAIL_SUBJECT",'Contact');
}
$name = stripslashes($_POST['name']);
$email = trim($_POST['email']);
$message = stripslashes($_POST['message']);
$custom = $_POST['fields'];
$custom = substr($custom, 0, -1);
$custom = explode(',', $custom);
$message_addition = '';
foreach ($custom as $c) {
if ($c !== 'name' && $c !== 'email' && $c !== 'message' && $c !== 'subject') {
$message_addition .= '<b>'.$c.'</b>: '.$_POST[$c].'<br />';
}
}
if ($message_addition !== '') {
$message = $message.'<br /><br />'.$message_addition;
}
$message = '<html><body>'.nl2br($message)."</body></html>";
$mail = mail(WEBMASTER_EMAIL, EMAIL_SUBJECT, $message,
"From: ".$name." <".$email.">\r\n"
."Reply-To: ".$email."\r\n"
."X-Mailer: PHP/" . phpversion()
."MIME-Version: 1.0\r\n"
."Content-Type: text/html; charset=utf-8");
if($mail)
{
echo '
<div class="alert alert-confirm">
<strong>Confirm</strong>: Your message has been sent. Thank you!
</div>
';
}
else
{
echo '
<div class="alert alert-error">
<strong>Error</strong>: Your message has not been send!
</div>
';
}
?>