Mailer.php
authorAlan Knowles <alan@roojs.com>
Tue, 22 Sep 2015 03:13:36 +0000 (11:13 +0800)
committerAlan Knowles <alan@roojs.com>
Tue, 22 Sep 2015 03:13:36 +0000 (11:13 +0800)
Mailer.php

index b3b7ebb..abfbd66 100644 (file)
@@ -298,9 +298,9 @@ class Pman_Core_Mailer {
             
             return $email;
         }
-        if ($this->debug) {
-            echo '<PRE>';echo htmlspecialchars(print_r($email,true));
-        }
+        
+        $this->log( htmlspecialchars(print_r($email,true)));
+        
         ///$recipents = array($this->email);
         $mailOptions = PEAR::getStaticProperty('Mail','options');
         //print_R($mailOptions);exit;
@@ -312,7 +312,7 @@ class Pman_Core_Mailer {
         
         $mail = Mail::factory($this->mail_method,$mailOptions);
         if ($this->debug) {
-            $mail->debug = $this->debug;
+            $mail->debug = (bool) $this->debug;
         }
         
         $email['headers']['Date'] = date('r'); 
@@ -426,8 +426,7 @@ class Pman_Core_Mailer {
     {
         
         
-        if($this->debug) {
-            echo "FETCH : $url\n";
+        $this->log( "FETCH : $url\n");
         }
         if ($url[0] == '/') {
             $ff = HTML_FlexyFramework::get();
@@ -527,9 +526,12 @@ class Pman_Core_Mailer {
     
     function log($val)
     {
-        if (!$debug) {
+        if (!$debug < 1) {
             return;
         }
+        if ($debug < 2) {
+            echo '<PRE>' . $val. "\n";
+        }
         $fh = fopen('/tmp/core_mailer.log', 'a');
         fwrite($fh, date('Y-m-d H:i:s -') . json_encode($val) . "\n");
         fclose($fh);