PHP表单电子邮件提交每次都不起作用

EDIT: This is different from the possible duplicate, as they never got the email. Mine sends randomly.

The code below has been working fine for almost a year. For about the past week, however, it only sends when it wants to. My guys use it at multiple locations on multiple devices, and the same thing is happeneing.

There's an html form that submits to this php code, which then emails me and displays an html confirmation page. They're getting the confirmation page, but I'm not getting the email. Later in the day, if I hit back, then submit again, I do get the email.

I can't figure it out. Any suggestions as to what's happening? I'm considering making a SQL database that it submits to first, so that I can look up what they entered incase I don't get the email.

Thanks!

<?php
if(isset($_POST['submit'])) {
$to = "email_removed@gmail.com";
$subject = "Daily Inventory Submission";

// data the visitor provided
$location_field = filter_var($_POST['location'], FILTER_SANITIZE_STRING);
$yourname_field = filter_var($_POST['yourname'], FILTER_SANITIZE_STRING);
$biscuitsfull_field = filter_var($_POST['biscuits_full'], FILTER_SANITIZE_STRING);
$biscuitspartial_field = filter_var($_POST['biscuits_partial'], FILTER_SANITIZE_STRING);
$biscuitsemergency_field = filter_var($_POST['biscuits_emergency'], FILTER_SANITIZE_STRING);
$gravyfull_field = filter_var($_POST['gravy_full'], FILTER_SANITIZE_STRING);
$gravypartial_field = filter_var($_POST['gravy_partial'], FILTER_SANITIZE_STRING);
$eggsfull_field = filter_var($_POST['eggs_fullflats'], FILTER_SANITIZE_STRING);
$eggspartial_field = filter_var($_POST['eggs_partial'], FILTER_SANITIZE_STRING);
$cheese_field = filter_var($_POST['cheese'], FILTER_SANITIZE_STRING);
$sausagefull_field = filter_var($_POST['sausage_full'], FILTER_SANITIZE_STRING);
$sausagepartial_field = filter_var($_POST['sausage_partial'], FILTER_SANITIZE_STRING);
$jalapenos_field = filter_var($_POST['jalapenos'], FILTER_SANITIZE_STRING);
$sprayoil_field = filter_var($_POST['spray_oil_cans'], FILTER_SANITIZE_STRING);
$pouroil_field = filter_var($_POST['pour_oil'], FILTER_SANITIZE_STRING);
$tofu_field = filter_var($_POST['tofu'], FILTER_SANITIZE_STRING);
$almondmilk_field = filter_var($_POST['almond_milk'], FILTER_SANITIZE_STRING);
$veganbutter_field = filter_var($_POST['vegan_butter'], FILTER_SANITIZE_STRING);
$realbutter_field = filter_var($_POST['real_butter'], FILTER_SANITIZE_STRING);
$bacon_field = filter_var($_POST['bacon'], FILTER_SANITIZE_STRING);
$togo_field = filter_var($_POST['to_go'], FILTER_SANITIZE_STRING);
$hereboats_field = filter_var($_POST['here_boats'], FILTER_SANITIZE_STRING);
$flour_field = filter_var($_POST['flour'], FILTER_SANITIZE_STRING);
$potatoes_field = filter_var($_POST['potatoes'], FILTER_SANITIZE_STRING);
$waters_field = filter_var($_POST['waters'], FILTER_SANITIZE_STRING);
$oj_field = filter_var($_POST['orange_juice'], FILTER_SANITIZE_STRING);
$topo_field = filter_var($_POST['topo'], FILTER_SANITIZE_STRING);
$cokes_field = filter_var($_POST['cokes'], FILTER_SANITIZE_STRING);
$comment = filter_var($_POST['comment'], FILTER_SANITIZE_STRING);




//constructing the message
$body = " 
Location: $location_field
 
Employee: $yourname_field

 

Biscuits_FULL:      $biscuitsfull_field

Biscuits_Partial:   $biscuitspartial_field

Biscuits_Emergency: $biscuitsemergency_field



Gravy_Full:    $gravyfull_field

Gravy_Partial: $gravypartial_field



Eggs_Full:    $eggsfull_field

Eggs_Partial: $eggspartial_field



Cheese:  $cheese_field



Sausage_Full:    $sausagefull_field

Sausage_Partial: $sausagepartial_field



Jalapenos:  $jalapenos_field



Spray Oil Cans:  $sprayoil_field

Pour Oil :       $pouroil_field



Tofu:         $tofu_field

Almond Milk:  $almondmilk_field

Vegan Butter: $veganbutter_field



Real Butter: $realbutter_field



Bacon: $bacon_field



To Go Boxes:  $togo_field

Here Boats:   $hereboats_field



Flour:    $flour_field

Potatoes: $potatoes_field



Waters:        $waters_field

Daiya:         $oj_field

Topos:         $topo_field

Cokes:         $cokes_field








Message:

 $comment";

mail($to, $subject, $body);

// redirect to confirmation
header('Location: confirmation.htm');
} else {
echo "Error, not sent";}
?>

I would suggest using a class specifically designed for this purpose instead of using the raw mail function, look up https://github.com/PHPMailer/PHPMailer.