i am developing small inventory model i trying to send mail if stock is less...please help me where to write and how : simple pdo mail function
as on stock is column name, when stock is less than 10 then mail should go automatically in pdo please help me without SMTP

include_once('database-config.php');
$email="abc@gmail.com";


$query = "SELECT slno, itemname FROM item WHERE as on stock = 10";

foreach ($dbh->query($query) as $row) {
    // Safe name for 70 char/line limit
    $itemname = (strlen($row['itemname']) > 40) ? (substr($row['itemname'], 0, 10) . '...') : $row['itemname'];
    // Prepare message data
    $subject = 'Out of stock - ' . $row['itemname'];
    $body = 'Product "' . $itemname . '" is out of stock.'  . "\r\n";
    $body .= 'Manage from http://localhost/oftest/login-system-in-php/guru-able/guru-able/default/adminhome.php?slno=' . $row['slno'] . "\r\n";
    
    mail($email, $subject, $body);