PHP Classes

minor corrections

Recommend this page to a friend!

      All In One - dSendMail2  >  All threads  >  minor corrections  >  (Un) Subscribe thread alerts  
Subject:minor corrections
Summary:suggested corrections to class code, MassMail example
Messages:2
Author:Michael Hosford
Date:2010-10-23 23:56:40
Update:2012-10-03 00:00:40
 

  1. minor corrections   Reply   Report abuse  
Picture of Michael Hosford Michael Hosford - 2010-10-23 23:56:40
Hi,

I was testing your dSendMail2 class, starting with the MassMail example, and found a couple of things need to be changed in order for it to work correctly:

example-MassMailer.php, lines 30-31:
var $logFolder = './log/';
var $logFile = "send-".date('Y-m-d H-i-s').".dat";

I had to change these lines to:
$m->logFolder = './log'; // note: removed trailing slash
$m->logFile = "send-".date('Y-m-d H-i-s').".dat";

dSendMail2.inc.php, line 537:
if(!$this->logFile)

I had to remove the "!" (negation) for this to work; otherwise the logfile is never opened!

I also added to the end of the fopen() call: 'or die("Cannot open log file.");'

Thanks for providing the class! I'll let you know if I find anything else that needs fixing. :-)

-MH

  2. Re: minor corrections   Reply   Report abuse  
Picture of Michael Hosford Michael Hosford - 2012-10-03 00:00:40 - In reply to message 1 from Michael Hosford
OK, so it's two years later, and I just realized that line 537 of dSendMail2.inc.php was correct in its original form.

The problem of the logfile not being opened occurred because I based my "mass mailer" code on the example code in example-MassMailer.php, which attempts to set the name of the logfile with the following code:

var $logFile   = "send-".date('Y-m-d H-i-s').".dat";

Here, $logFile is being assigned a string value, but dSendMail2.inc.php expects $logFile to be the handle of an open file.

Since $logFile wasn't empty, dSendMail2.inc.php didn't open a new logfile, but when it tried to write to the file, it couldn't.

So I commented out the above line and restored line 537 to:
if(!$this->logFile)

which works better because it doesn't create a new logfile every time the _log() function is called. :-)