How can PHP be used to send email notifications when a form is submitted on a website?

To send email notifications when a form is submitted on a website using PHP, you can use the `mail()` function in PHP to send an email to a specified email address. You will need to set the appropriate headers, such as the recipient email address, subject, and content of the email. Additionally, you can use PHP to retrieve the form data and include it in the email body.

<?php
if($_SERVER["REQUEST_METHOD"] == "POST") {
    $to = "recipient@example.com";
    $subject = "Form Submission";
    $message = "Name: " . $_POST['name'] . "\n";
    $message .= "Email: " . $_POST['email'] . "\n";
    $message .= "Message: " . $_POST['message'];

    $headers = "From: sender@example.com" . "\r\n" .
               "Reply-To: sender@example.com" . "\r\n" .
               "X-Mailer: PHP/" . phpversion();

    mail($to, $subject, $message, $headers);
}
?>