Mail function in php not sending emails

Im trying to send an alert to an email depending on the value of a variable $alert. However, I can’t send any emails no matter what email address I use, but I do get the echo “Email enviado(sent)”, so I know the if structure is working properly! I don’t know if it is of any relevance, but I’m hosting my php file at IONOS. Any help please!

<?php
    date_default_timezone_set('America/Mexico_City');
    $hoy = getdate();
    $fecha = $hoy['hours'] . ":" . $hoy['minutes'] . ":" . $hoy['seconds'] . " " . $hoy['mday'] . "/" . $hoy['mon'] . "/" . $hoy['year'];

    $servername = "db5001424197.hosting-data.io";

    // REPLACE with your Database name
    $dbname = "dbs1200873";
    // REPLACE with Database user
    $username = "dbu300985";
    // REPLACE with Database user password
    $password = "Batman1998#";

    // Keep this API Key value to be compatible with the ESP32 code provided in the project page. If you change this value, the ESP32 sketch needs to match
    $api_key_value = "tPmAT5Ab3j7F9";

    $api_key = $ID = $porcentaje = "";

    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        $api_key = test_input($_POST["api_key"]);
        if($api_key == $api_key_value) {
            $ID = test_input($_POST["ID"]);
            $alarma = test_input($_POST["alarma"]);
            $pin = test_input($_POST["pin"]);

            if ($pin == 0 ){
                $pin = "none";
            }
            // Create connection
            $conn = new mysqli($servername, $username, $password, $dbname);
            // Check connection
            if ($conn->connect_error) {
                die("Connection failed: " . $conn->connect_error);
            } 
            //**********SISTEMA ANTERIOR**********//
            $sql = "UPDATE instituto SET ultCon = '$fecha' WHERE ID = '$ID'";
            $sql2 = "UPDATE instituto SET pin = '$pin' WHERE ID = '$ID'";
              
            $alter = $conn->query($sql);
            $alter2 = $conn->query($sql2);
            
            if ($alarma == 1){
                $email_from ="[email protected]";

                $email_subject = "Alarma encendida";

                $email_body = "Pin Activado: $pin.n".
                    "Botonera Activada: Si.n".
                    "Sirena Activada: Si.n";

                $to = "[email protected]";

                $headers = "From: $email_from rn";

                $headers .= "Reply-To: $email_from rn";

                mail($to,$email_subject,$email_body,$headers);

                echo "Email enviado";
            }


            echo "¡Conexión exitosa!";
        
            $conn->close();
        }
        else {
            echo "Wrong API Key provided.";
        }

    } else {
        echo "No data posted with HTTP POST.";
    }

    function test_input($data) {
        $data = trim($data);
        $data = stripslashes($data);
        $data = htmlspecialchars($data);
        return $data;
    }
    ?>