-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnewsletter.php
More file actions
35 lines (29 loc) · 1.07 KB
/
newsletter.php
File metadata and controls
35 lines (29 loc) · 1.07 KB
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
<?php
/* Newsletter form script */
// Set error level
error_reporting(E_ALL ^ E_NOTICE);
// Set defaults
$error = false;
$message = Array();
// Check name
if(isset($_GET['subscribeemail'])){
if($_GET['subscribeemail'] == '' || $_GET['subscribeemail'] == 'Enter your emai address'){
$error[] = 'Email field required.';
}
$headers = 'From: River to Well Website <info@rivertowell.com' . ">\r\n" . 'X-Mailer: PHP/' . phpversion();
$message = "Email address to signup: " . $_GET['subscribeemail'] . "\r\n\r\n";
// Send email if no error
if ($error){
echo json_encode(array('status' => 'failed', 'message' => 'Error in sending form.'));
} else {
$send_contact = mail('info@rivertowell.com', 'Newsletter Signup - River to Well', $message, $headers);
if ($send_contact){
echo json_encode(array('status' => 'ok', 'message' => 'Email Sent'));
} else {
echo json_encode(array('status' => 'failed', 'message' => 'Error in sending form.'));
}
}
} else {
echo json_encode(array('status' => 'failed', 'message' => 'Error in sending form.'));
}
?>