-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpage-sendemail.php
56 lines (41 loc) · 1.75 KB
/
page-sendemail.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
<!DOCTYPE html>
<html lang="en">
<?php get_header(); ?>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Freelance Programmer - Talented Developer For Hire | CodeSpread</title>
</head>
<?php
// Define some constants
define("RECIPIENT_NAME", "CodeSpread");
$addresses = array("[email protected]", "[email protected]");
//define( "RECIPIENT_EMAIL", $addresses );
// Read the form values
$success = false;
$senderName = isset($_POST['name']) ? preg_replace("/[^\.\-\' a-zA-Z0-9]/", "", $_POST['name']) : "";
$senderEmail = isset($_POST['email']) ? preg_replace("/[^\.\-\_\@a-zA-Z0-9]/", "", $_POST['email']) : "";
$subject = isset($_POST['subject']) ? preg_replace("/[^\.\-\' a-zA-Z0-9]/", "", $_POST['subject']) : "";
$message = isset($_POST['message']) ? preg_replace("/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", "", $_POST['message']) : "";
// If all values exist, send the email
if ($senderName && $senderEmail && $subject && $message) {
$recipient = RECIPIENT_NAME . " < " . RECIPIENT_EMAIL . ">";
$headers = "New Message: " . $senderName . " <" . $senderEmail . ">";
$msgBody = " Subject: " . $subject . " Message: " . $message . "";
$success = mail($to = implode(", ", $addresses), $headers, $msgBody);
//Set Location After Successsfull Submission
$response = "Message sent";
header("refresh:5;url=page-contact.php");
} else {
//Set Location After Unsuccesssfull Submission
$response = "Message couldn't be delivered.";
header("refresh:5;url=page-contact.php");
}
?>
<section class="video-section">
<h1>Contact <span style="color:#3080EC">Us</span></h1>
<p><?php echo $response ?></p>
</section>
<?php get_footer(); ?>
</html>