Skip to content

Commit b0ac961

Browse files
authored
mail php file
1 parent 1911cd7 commit b0ac961

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

mail/contact_me.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
// Check for empty fields
3+
if(empty($_POST['name']) ||
4+
empty($_POST['email']) ||
5+
empty($_POST['phone']) ||
6+
empty($_POST['message']) ||
7+
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
8+
{
9+
echo "No arguments Provided!";
10+
return false;
11+
}
12+
13+
$name = strip_tags(htmlspecialchars($_POST['name']));
14+
$email_address = strip_tags(htmlspecialchars($_POST['email']));
15+
$phone = strip_tags(htmlspecialchars($_POST['phone']));
16+
$message = strip_tags(htmlspecialchars($_POST['message']));
17+
18+
// Create the email and send the message
19+
$to = '[email protected]'; // Add your email address inbetween the '' replacing [email protected] - This is where the form will send a message to.
20+
$email_subject = "Website Contact Form: $name";
21+
$email_body = "You have received a new message from your website contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email_address\n\nPhone: $phone\n\nMessage:\n$message";
22+
$headers = "From: [email protected]\n"; // This is the email address the generated message will be from. We recommend using something like [email protected].
23+
$headers .= "Reply-To: $email_address";
24+
mail($to,$email_subject,$email_body,$headers);
25+
return true;
26+
?>

0 commit comments

Comments
 (0)