-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend_email.php
More file actions
29 lines (24 loc) · 759 Bytes
/
send_email.php
File metadata and controls
29 lines (24 loc) · 759 Bytes
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
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
// Set the recipient email address
$to = "rohanus98@gmail.com";
// Set the email subject
$subject = "New Message from $fname $lname: $subject";
// Build the email body
$body = "First Name: $fname\nLast Name: $lname\nEmail: $email\n\n$message";
// Set additional headers
$headers = "From: $email\r\n";
$headers .= "Reply-To: $email\r\n";
// Send the email
if (mail($to, $subject, $body, $headers)) {
echo "Email sent successfully!";
} else {
echo "Email sending failed!";
}
}
?>