How can PHP be integrated with a contact form for email forwarding purposes?

To integrate PHP with a contact form for email forwarding purposes, you can use the PHP `mail()` function to send the form data to a specified email address. You will need to set up your HTML contact form with appropriate input fields and then create a PHP script to process the form data and send it via email.

<?php
if(isset($_POST['submit'])){
    $to = "recipient@example.com";
    $subject = "Contact Form Submission";
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];
    
    $body = "Name: $name\n";
    $body .= "Email: $email\n";
    $body .= "Message: $message\n";
    
    if(mail($to, $subject, $body)){
        echo "Message sent successfully!";
    } else{
        echo "Error sending message.";
    }
}
?>