D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
u193541357
/
public_html
/
assets
/
Filename :
mail.php
back
Copy
<?php // Only process POST requests. if ($_SERVER["REQUEST_METHOD"] == "POST") { // Get the form fields and remove whitespace. $name = strip_tags(trim($_POST["name"])); $name = str_replace(array("\r", "\n"), array(" ", " "), $name); $email = filter_var(trim($_POST["email"]), FILTER_SANITIZE_EMAIL); $phone = trim($_POST["phone"]); $subject = trim($_POST["subject"]); $message = trim($_POST["message"]); // Check that data was sent to the mailer. if (empty($name) or empty($subject) or empty($message) or empty($phone) or !filter_var($email, FILTER_VALIDATE_EMAIL)) { // Set a 400 (bad request) response code and exit. http_response_code(400); header("Location: contact.php?status=error"); exit; } // Set the recipient email address. $recipient = "nexusad99@gmail.com"; // Set the email subject. $subject = "Contact from $name"; // Build the email content. $email_content = "Name: $name\n"; $email_content .= "Email: $email\n\n"; $email_content .= "Phone: $phone\n\n"; $email_content .= "Subject: $subject\n\n"; $email_content .= "Message:\n$message\n"; // Build the email headers. $email_headers = "From: $name <$email>"; // Send the email. if (mail($recipient, $subject, $email_content, $email_headers)) { // Redirect to contact page with success message. header("Location: https://nexusadvt.com/contact.php?status=success"); } else { // Redirect to contact page with error message. header("Location: https://nexusadvt.com/contact.php?status=error"); } exit; } else { // Redirect to contact page for invalid requests. header("Location: https://nexusadvt.com/contact.php?status=forbidden"); exit; }