I'm having an issue where my PHP mail code runs every night at like 11:30pm. I'm sure no one is clicking the form submission button. The email contents are empty.
In my PHP mail code, I add the contents to a database just in case the email does not go through, then send the email as well.
Thanks
Form:
<form action="background/mail.php" method="POST">
    <div class="row">
        <div class="six columns">
            <label>Your email</label>
            <input class="u-full-width" type="email" placeholder="example@validmail.com" name="email">
        </div>
        <div class="six columns">
            <label>Reason for contacting</label>
            <select class="u-full-width" name="reason">
                <option>Inquiry</option>
                <option>Order</option>
                <option>Other</option>
            </select>
        </div>
    </div>
    <div class="row">
        <div class="u-full-width">
            <label>Message</label>
            <textarea class="u-full-width" placeholder="Enter message here" name="message"></textarea>
          <input class="button-primary" type="submit" value="Submit">
        </div>
    </div>
</form>
mail.php:
<?php
    $to = "support@website.ca";
    $reason = "CUSTOMER MAIL: " . $_POST['reason'];
    $email = $_post['email'];
    $msg = $_POST['message'] . "\nemail: " . $email;
    $header = "MIME-Version: 1.0\r\n";
    $header.= "Content-type: text/html\r\n";
    $header.= "From: " . $email . "\r\n";
    $header.= "Reply-to: support@website.ca\r\n" . "X-Mailer: PHP/" . phpversion();
    require("login.php");
    $sql = "INSERT INTO emails (email, message, reason) VALUES ('$email','$msg','$reason')";
    if($conn->query($sql) === TRUE){
        mail($to,$reason,$msg, $header);
        echo "Added to database, mail sent.";
    } else {
        echo "Error: " . $sql . "<br>" . $conn->error;
    }
    $conn->close();
?>
 
     
     
    