What is the recommended function in PHP to send emails?
To send emails in PHP, the recommended function is `mail()`. This function allows you to send emails using a simple syntax and is widely supported by most PHP installations. To use `mail()`, you need to provide the recipient's email address, subject, message content, and optional additional headers.
$to = "recipient@example.com";
$subject = "Test Email";
$message = "This is a test email.";
$headers = "From: sender@example.com";
mail($to, $subject, $message, $headers);