-
Notifications
You must be signed in to change notification settings - Fork 0
/
send.php
25 lines (24 loc) · 893 Bytes
/
send.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
//Contact Form in PHP
<?php
$name = htmlspecialchars($_POST['field name']);
$email = htmlspecialchars($_POST['field email']);
$subject = htmlspecialchars($_POST['field']);
$message = htmlspecialchars($_POST['field textarea']);
if(!empty($email) && !empty($message)){
if(filter_var($email, FILTER_VALIDATE_EMAIL)){
$receiver = "[email protected]"; //enter that email address where you want to receive all messages
$subject = "From: $name <$email>";
$body = "Name: $name\nEmail: $email\nSubject: $subject\nMesage: $message\n";
$sender = "From: $email";
if(mail($receiver, $subject, $body, $sender)){
echo "Your message has been sent";
}else{
echo "Sorry, failed to send your message!";
}
}else{
echo "Enter a valid email address!";
}
}else{
echo "Email and message field is required!";
}
?>