First, create a sendEmail.php file in web document root and we have to use the below-mentioned script in it to send email using a PHP script. Change the $to_email with a recipient email address, $body and $subject as you require, and $from_email with a sender email address here.

BY Best Interview Question ON 07 Aug 2019

Example

$to_email = "[email protected]";
$subject = "Simple Email Test via PHP";
$body = "Hi,nn This is test email send by PHP Script";
$headers = "From: [email protected]";
if ( mail($to_email, $subject, $body, $headers)) {
     echo("Email successfully sent to $to_email...");
} else {
     echo("Email sending failed...");
}