What are some common PHP scripts or resources for creating email forms?

Creating email forms in PHP requires handling form submission, validating input, and sending the email. One common approach is to use the PHP `mail()` function to send the email. This function takes parameters for the recipient email address, subject, message, and additional headers.

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $recipient = "recipient@example.com";
    $subject = $_POST['subject'];
    $message = $_POST['message'];
    $headers = "From: " . $_POST['email'];

    if (mail($recipient, $subject, $message, $headers)) {
        echo "Email sent successfully!";
    } else {
        echo "Email sending failed.";
    }
}
?>