PHP mail test from localhost

<?php 
    ini_set('display_errors', 1);
    error_reporting(E_ALL);
 
    $from = "foo@example.com";
    $to = "bar@example.com";
    $subject = "PHP Mail Test script";
    $message = "This is a test to check the PHP Mail functionality";
 
    $state = mail($to, $subject, $message);
 
    echo "state: $state";
?>
 
# Link
http://php.net/manual/de/function.mail.php