DataObjects/Core_watch.php
[Pman.Core] / Mailer.php
index ff7aa90..2ec116d 100644 (file)
@@ -46,6 +46,7 @@ class Pman_Core_Mailer {
     var $template       = false; /* string */
     var $replaceImages  = false; /* boolean */
     var $rcpts   = false;
+    var $templateDir = false;
     
     var $images         = array(); // generated list of cid images for sending
     
@@ -90,8 +91,14 @@ class Pman_Core_Mailer {
         
         require_once 'HTML/Template/Flexy.php';
         
+        $tmp_opts = array();
+        if (!empty($this->templateDir)) {
+            $tmp_opts['templateDir'] = $this->templateDir;
+        }
+        
+        
         $htmlbody = false;
-        $htmltemplate = new HTML_Template_Flexy(  );
+        $htmltemplate = new HTML_Template_Flexy( $tmp_opts );
 
         if (is_string($htmltemplate->resolvePath('mail/'.$templateFile.'.body.html')) ) {
             // then we have a multi-part email...
@@ -104,14 +111,12 @@ class Pman_Core_Mailer {
             
             $htmlbody = $this->htmlbodytoCID($htmlbody);
             
-             
+              
         }
         
+        $tmp_opts['nonHTML'] = true;
         
-        
-        $template = new HTML_Template_Flexy( array(
-                'nonHTML' => true,
-        ));
+        $template = new HTML_Template_Flexy(  $tmp_opts );
         
         $template->compile('mail/'. $templateFile.'.txt');
         
@@ -191,11 +196,16 @@ class Pman_Core_Mailer {
         ///$recipents = array($this->email);
         $mailOptions = PEAR::getStaticProperty('Mail','options');
         $mail = Mail::factory("SMTP",$mailOptions);
-        $headers['Date'] = date('r');
+        $headers['Date'] = date('r'); 
         if (PEAR::isError($mail)) {
             return $mail;
         } 
         $rcpts = $this->rcpts == false ? $email['recipents'] : $this->rcpts;
+        
+        if (!empty($this->contents['bcc']) && is_array($this->contents['bcc'])) {
+            $rcpts =array_merge(is_array($rcpts) ? $rcpts : array($rcpts), $this->contents['bcc']);
+        }
+        
         $oe = error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT);
         $ret = $mail->send($rcpts,$email['headers'],$email['body']);
         error_reporting($oe);