What are the best practices for sending notification emails to administrators when a user submits a form on a PHP website?

When a user submits a form on a PHP website, it is important to notify administrators so they can take appropriate action. One way to achieve this is by sending notification emails to administrators whenever a form is submitted. This can be done by using the PHP `mail()` function to send an email to the designated administrator email address with the relevant information from the form submission.

// Get form data
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];

// Set up email parameters
$to = 'admin@example.com';
$subject = 'New form submission';
$body = "Name: $name\nEmail: $email\nMessage: $message";
$headers = 'From: webmaster@example.com';

// Send email notification to administrator
$mail_sent = mail($to, $subject, $body, $headers);

if($mail_sent) {
    echo 'Notification email sent to administrator';
} else {
    echo 'Failed to send notification email';
}