[thelist] PHP Mail() function

Santilal Parbhu santilal at scorpioneng.co.nz
Tue Jun 3 04:30:46 CDT 2014


I have been tied up with other things for a few days and have not been able
to work on this job.  However, I'm back on it now.

Where do I find these logs.  I have had a look but could not find them.  Do
I have to request them from my hosting provider?

I am building up my message using a variable $body.  I initialise this to 

$body = "";

Then I add to the message using

$body .= "new string";

$body .= "another new string";

And so on.

Eventually I send the email using


I went through and disabled all of the "$body .=" instructions and then
re-enabled them one at a time.  When I got the following line

$body .= "\n\n\n";

the email failed.  So then I thought there must be something in this line
that is causing the mail to fail.  So I disabled this line again by
commenting it out and resent the mail expecting it to work.  However, it did
not.  So now I am thinking it is not my code but something on the server
side so perhaps it is the logs that hold the only clue.

Thanks everyone for your help.


Santilal Parbhu
Scorpion Engineering Limited
PO Box 171
Phone: +64 3 440 2100
Mobile: +64 21 2655991
Email: santilal at scorpioneng.co.nz
Web: www.scorpioneng.co.nz

-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Bob Meetin
Sent: Sunday, 1 June 2014 3:13 a.m.
To: thelist at lists.evolt.org
Subject: Re: [thelist] PHP Mail() function

Hmm, and if the error or mail logs are not giving you anything meaningful,
you can probably add a few lines of code to your php script using fopen and
fwrite to create your own text logfile. You could also dabble and change the
script to pull a couple different lines for tests. Eliminate one variable at
a time.


$datetime = date('Y-m-d-H-i-s');

$text --> maybe some output from the query, up to you

if ( some_condition ) // optional
   $logfile = "$path/log.txt";
   $fpi = fopen("$logfile", "a"); // a to append
   fwrite($fpi, "$datetime|$text|$text2\n");
   fclose ($fpi);


On 05/31/2014 08:58 AM, Hassan Schroeder wrote:
> On Fri, May 30, 2014 at 4:25 PM, Santilal Parbhu 
> <santilal at scorpioneng.co.nz> wrote:
>> Hey thanks for the help.  However, I have found that I am barking up 
>> the wrong tree.  I inserted a test script and found that it worked.  
>> So then I disabled everything in my script that accesses the database 
>> and essentially just left the mail() part.  This also worked.  So 
>> there must be something in the data that I select that is stopping 
>> the email going out.  Perhaps a control character or similar.  Is this
> Anything's possible :-)
> However, to repeat: what's in the logs? If mail sending is failing due 
> to some charset/encoding issue, I would expect to see that logged.
> Actual data from your environment trumps guessing in most cases...

Bob Meetin
303-926-0167 (m)


* * Please support the community that supports you.  * *

For unsubscribe and other options, including the Tip Harvester and archives
of thelist go to: http://lists.evolt.org Workers of the Web, evolt ! 

More information about the thelist mailing list