forked from Sibelious/littleochie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmailer.php
49 lines (39 loc) · 1.43 KB
/
mailer.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
<?php
if(isset($_POST['email'])) {
// EDIT THE BELOW TWO LINES AS REQUIRED
$email_to = "[email protected]";
$email_subject = "Message From Gridz Site Template";
function errorMesg() {
// Error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['name']) ||
!isset($_POST['email']) ||
!isset($_POST['comments'])) {
errorMesg();
}
$name = $_POST['name']; // required
$email_from = $_POST['email']; // required
$mysubject = $_POST['mysubject']; // required
$comments = $_POST['comments']; // required
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Name: ".clean_string($name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Subject: ".clean_string($mysubject)."\n";
$email_message .= "Comments: ".clean_string($comments)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
<?php
}
?>