-
Notifications
You must be signed in to change notification settings - Fork 0
/
sendmail.php
37 lines (28 loc) · 1.01 KB
/
sendmail.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
<?php
// Email Submit
// Note: filter_var() requires PHP >= 5.2.0
if ( isset($_POST['email']) && isset($_POST['name']) && isset($_POST['subject']) && isset($_POST['budget']) && isset($_POST['message']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) ) {
// detect & prevent header injections
$test = "/(content-type|bcc:|cc:|to:)/i";
foreach ( $_POST as $key => $val ) {
if ( preg_match( $test, $val ) ) {
exit;
}
}
$headers = "From: " . $_POST["name"] . "<" . $_POST["email"] . ">" . "\r\n";
$headers .= "Reply-To: " . $_POST["email"] . "\r\n";
$headers .= "X-Mailer: PHP/" . phpversion();
$headers .= "Content-Type: text/html; charset=utf-8\r\n";
$headers .= "X-Priority: 1\r\n";
$message = $_POST['message'];
$budget = $_POST['budget'];
$name = $_POST['name'];
$body = "#Name: " . $name . ", ";
$body .= "#Budget: " . $budget . ", ";
$body .= "#Message: " . $message. ", ";
//
mail( "[email protected]", $_POST['subject'], $body, $headers );
// ^
// Replace with your email
}
?>