Yimin Rong Yimin Rong - 3 months ago 8
PHP Question

Strange mail() behaviour

Is it possible that email sent via

mail()
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
crc32()
hash.

Even though
mail()
is returning
true
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
sendmail
log, so apparently they are going out.

We're setting
From
with a confirmed working email address. Nothing bounces back. Also tried setting
Return-Path
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
curl
from the page with a "bad name" to a page with a "good name"! FYI, the bad name is apparently
ws.php
!

Answer

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!