How can PHP be integrated with a Bootstrap 4 form to send an email upon submission?
To integrate PHP with a Bootstrap 4 form to send an email upon submission, you can use the PHP `mail()` function to send an email with the form data. You will need to set up the form to submit to a PHP script that processes the form data and sends the email.
```php
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$to = "recipient@example.com";
$subject = "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 "Email sent successfully!";
} else {
echo "Email sending failed.";
}
}
?>
```
Make sure to replace `recipient@example.com` with the actual email address where you want to receive the form submissions. This code snippet should be placed at the top of the PHP file that the form submits to.