How can a mailto link be included in a PHP script to enable direct responses to form submissions?

To include a mailto link in a PHP script for direct responses to form submissions, you can use the mail() function in PHP to send an email to the specified email address. You can retrieve the user's email address from the form submission and include it in the mailto link to enable direct responses. Additionally, you can customize the email content with the form data using PHP variables.

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $user_email = $_POST['email']; // Retrieve user's email address from form submission
    $subject = "Response to your inquiry";
    $message = "Thank you for your inquiry. We will get back to you shortly.";
    $headers = "From: your-email@example.com"; // Replace with your email address

    // Send email using mail() function
    mail("{$user_email}", $subject, $message, $headers);
    echo "Email sent successfully!";
}
?>