Yimin Rong Yimin Rong - 1 year ago 55
PHP Question

Strange mail() behaviour

Is it possible that email sent via

won't be sent based on the originating page?

I have two pages, both are sending exactly the same content, in that for
$result=mail($to, $subject, $message, $headers);
, the result and parameters are byte-for-byte equal, with the same

Even though
is returning
in all cases, we're getting emails for only one of the pages. Checked all the folders, including Spam and Trash. Tech support at the server side says they are seeing them in the
log, so apparently they are going out.

We're setting
with a confirmed working email address. Nothing bounces back. Also tried setting
just to see, nothing.

Have also tested sending just regular emails, i.e. not identical, and still the same results. Emails from one page are consistently not received, while those from the other are.

I have never seen anything like this before. Can anyone shed some light on the issue?

Latest developments:

  • the code is now identical on both pages; still receiving emails from only one!

  • support just shrugged and said "must be the filename, try a different one"

That's not a great fix for us because it would mean canceling an approved binary at the app distribution site, resubmitting a revised one, then waiting for the approval process. Can take weeks.

Instead, what we're doing is dispatching using
from the page with a "bad name" to a page with a "good name"! FYI, the bad name is apparently

Answer Source

We're seeing this happen, too. We traced the cause to an admin adding mail.add_x_header = On to php.ini. We found this actually injects several headers containing the file name into emails:

  • X-PHP-Originating-Script
  • X-EN-Info
  • X-EN-CGIPath

With today's neural-network self-teaching autonomous filters, common file names like ws.php can be associated with spam. It doesn't care why, just plays the odds. The filter sees something in the list mentioned a lot of times, and suddenly your emails will trip the spam filters.

We had the option to change the file name, but I like your approach of using curl to redirect to a safe page!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download