0

I'm trying to determine why we're not receiving mail from our website forms.

There was a change in ownership at our hosting company, the forms stopped working, and the new management seems clueless.

There is no error log and no php.ini file in the files I can see. Here is the phpinfo: http://www.fryermachine.com/phpinfo.php.

Here is the mail() code...

    <?php

error_reporting(-1);
ini_set('display_errors', 'On');
set_error_handler("var_dump");

if ($_POST['submit']) {
$to = 'service@fryermachine.com';
//$to = 'brinster@digitmedia.com';
$subject = 'Support email from FryerMachine.com';
$message = "FIRST NAME: " . $_POST['First_Name'] . "\r\n" . "LAST NAME: " . $_POST['Last_Name'] . "\r\n" . "COMPANY: " . $_POST['Company'] . "\r\n" .  "PHONE: " . $_POST['Phone'] . "\r\n" . "EMAIL: " . $_POST['Email'] . "\r\n" .  "MODEL: " . $_POST['Model'] . "\r\n" . "SN: " . $_POST['SN'] . "\r\n" . "CONTROL: " . $_POST['Control'] . "\r\n" ."MESSAGE: " . $_POST['Message'] . "\r\n";

$headers = 'From: service@fryermachine.com';

if (!mail($to,$subject,$message,$headers)) {
echo "<p>There was a problem submitting your form.  Please <a href=\"mailto:info@fryermachine.com\">contact us</a>.</p>";
} else { 
echo "<div class=\"thanks\"><p>Thank you for your inquiry.  We will respond as soon as possible.</p></div>";
} ?>

Using this...

    error_reporting(-1);
ini_set('display_errors', 'On');
set_error_handler("var_dump");

I get this output. And while I see all the vars for the form, I do not see any error.

Copyright © int(2) string(386) "date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone." string(42) "/virtual/home/fryer/public_html/footer.php" int(7) array(8) { ["_GET"]=> array(0) { } ["_POST"]=> array(11) { ["First_Name"]=> string(5) "Barry" ["Last_Name"]=> string(8) "Brinster" ["Company"]=> string(10) "Digitmedia" ["Phone"]=> string(10) "6093674793" ["Email"]=> string(23) "brinster@digitmedia.com" ["Model"]=> string(7) "3242342" ["SN"]=> string(5) "23232" ["Control"]=> string(4) "3232" ["Message"]=> string(4) "test" ["g-recaptcha-response"]=> string(484) "03AGdBq26aa_IGjWkjBx6AD-3vknIRZd953gdoDBunlELaN_OHWODA7SkGVHoqIlHUHFKnAvxUJMnLS0m4rHo0uiCWoCeo2f_IFF_Oe99OLEEMbLJqpPqfm6Fo2JQQOIP7M41LucLyMBiGgelN9Mk8hz8JP2ZUNOOzRcw5bjwh-0deSUm6jEbELYM29hAuO_G9h0rpoeA51cB4GF6hgVCsXmf2DUB_7Jz2W4Ir3RcBqtu2kBPlszfc9vODzRAgyE9p2t_Iaw4GjTQ6gTn5xEl4nDj7fYJNGKlpcK9s6472jbqeO_fHPxoufHWFk82yJqzzYfHYnBo5zgS1AZcgYuBPfLgoRhqtOS4U2XpxxYLp0_UPFMQEt73N3FbMACh6IqywJTCP7NVWBw7VGhpFBVhe6yXeYG8XTEMPCkXAIsf4yhKvIbOV0-aAld5_qWXEoFScm3H8fr1f1U61uAa48UYXVcIKIcaHvtJ0qA" ["submit"]=> string(6) "Submit" } ["_COOKIE"]=> array(3) { ["_ga"]=> string(27) "GA1.2.1114367905.1611002481" ["_gid"]=> string(27) "GA1.2.2097634062.1639520206" ["_gat_gtag_UA_80412166_1"]=> string(1) "1" } ["_FILES"]=> array(0) { } ["to"]=> string(24) "service@fryermachine.com" ["subject"]=> string(35) "Support email from FryerMachine.com" ["message"]=> string(169) "FIRST NAME: Barry LAST NAME: Brinster COMPANY: Digitmedia PHONE: 6093674793 EMAIL: brinster@digitmedia.com MODEL: 3242342 SN: 23232 CONTROL: 3232 MESSAGE: test " ["headers"]=> string(30) "From: service@fryermachine.com" } 2021 Fryer Machine Systems, Inc.
webguy
  • 664
  • 10
  • 27
  • 1
    Just about everything you need to know about and investigate for this sort of thing is covered in the main answer at [PHP mail function doesn't complete sending of e-mail](https://stackoverflow.com/questions/24644436/php-mail-function-doesnt-complete-sending-of-e-mail) – ADyson Dec 15 '21 at 15:56
  • For the date, see this: https://stackoverflow.com/a/16765214/231316 – Chris Haas Dec 15 '21 at 15:58
  • 1
    The tl;dr for email is that there's a major difference between not sending, and not receiving. – Chris Haas Dec 15 '21 at 16:00

1 Answers1

0

Edit: I have found this other SO post explaining lots of possible things that surely complement and expand my answer below: PHP mail function doesn't complete sending of e-mail


Looks like your server MTA (Mail Transport Agent) receives the mail correctly but it is not able to resend it. So you should fix it adding a correct Return-path mail header or checking main hosting account inbox.

Short explanation:

In order to get the MTA errors you should use the 5th mail() parameter in this way to set a correct Return-path mail header:

mail($to,$subject,$message,$headers,'-fexample@email.com')

where example@email.com should be a valid email with its MX dns domain record set in same server to avoid to try to resend it out of the server again, and if fails then remain in a loop during days in mail queue until it could be automatically deleted or resent to root server mail account.

This could help you to receive the MTA errors correctly and to know the MTA errors reported and fix the issue based in them.

Long explanation:

What is happening when you are not getting PHP errors using mail() despite you have set error_reporting and display_errors to show them?

Well, surely it means there are none.

So, what happens?

The mail() function was able to send it correctly to the MTA queue and then your MTA manages it trying to send it to the destinations set in mail headers.

But if your MTA is not able to send it then it uses the value set in Return-path header to return the mail to the supposed sender with an description of the error, that will help to fix the issue.

So, where are they now?

In some hostings the Return-path header is automatically set to the account@hostname, where:

  • account: It is the name of your linux user account, used also in /home/account, by instance myaccount (so /home/myaccount)
  • hostname: It is the server hostname, like vps007.hostingcompany.com

So the final Return-path header will look like this in this example data:

Return-path: <myacccount@vps007.hostingcompany.com>

The inbox of that email (in our example: myacccount@vps007.hostingcompany.com) usually do not exist at all, but some servers manage that emails redirecting them to main user hosting account inbox, storing them there, that could be in /home/myaccount/mail/new (like in cPanel for example).

That inbox rarely is never checked by hosting users because most of them have no idea that it exists or how to reach it.

Because that emails are only stored by the own MTA server, and mostly used to send server error messages related to the account, that folder uses few space and nobody notices it during long time.

In cPanel, for example, you could reach them via webmail easilly via its panel. (I really do not know other webhosting panels, but they used to do similar things).

In other servers all those emails could end in server root mail inbox, then it is impossible to reach if you are in a shared hosting and your hosting staff should manage them.

Btw, if you try to send emails from outside the server to this kind of account emails like myacccount@vps007.hostingcompany.com they usually are not accepted by the MTA filters.

masterguru
  • 549
  • 4
  • 10