This repository was archived by the owner on Nov 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend-mail.php
More file actions
55 lines (45 loc) · 1.33 KB
/
send-mail.php
File metadata and controls
55 lines (45 loc) · 1.33 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
// site owner
$site_name = 'Photography HTML5 Template';
$sender_domain = 'server@pixelwars.org';
$to = 'info@johndoe.com';
// contact form fields
$name = trim( $_POST['name'] );
$email = trim( $_POST['email'] );
$subject = trim( $_POST['subject'] );
$message = trim( $_POST['message'] );
$url = trim( $_POST['url'] );
// check for error
$error = false;
if ( $name === "" ) { $error = true; }
if ( $email === "" ) { $error = true; }
if ( $subject === "" ) { $error = true; }
if ( $message === "" ) { $error = true; }
// anti-spam check
// http://nfriedly.com/techblog/2009/11/how-to-build-a-spam-free-contact-forms-without-captchas/
// if the url field is empty
if(isset($url) && $url == ''){
// if no error, then send mail
if ( $error == false )
{
$body = "Name: $name \n\nEmail: $email \n\nMessage: $message";
$headers = "From: " . $site_name . ' <' . $sender_domain . '> ' . "\r\n";
$headers .= "Reply-To: " . $name . ' <' . $email . '> ' . "\r\n";
$mail_result = mail( $to, $subject, $body, $headers );
if ( $mail_result == true )
{ echo 'success'; }
else
{ echo 'unsuccess'; }
}
else // not validated
{
echo 'error';
}
// end if
}
else // BOT DETECTED - lets lie to it
{
//echo "Thanks, We'll get back to you as soon as possible";
echo 'success';
}
?>