DataObjects/pman.links.ini
[Pman.Core] / Mailer.php
index 0b4dc74..dd5cfe0 100644 (file)
@@ -20,6 +20,7 @@
        page => 
        contents
        template
+       html_locale => 'en' == always use the 'english translated verison'
        replaceImages => true|false,
        locale => 'en' .... or zh_hk....
        rcpts => array()   // override recipients..
@@ -233,8 +234,8 @@ class Pman_Core_Mailer {
                 $mime->addAttachment(
                         $attch['file'],
                         $attch['mimetype'],
-                        $attch['name'],
-                        false
+                        (!empty($attch['name'])) ? $attch['name'] : '',
+                        true
                 );
             }
             
@@ -256,11 +257,17 @@ class Pman_Core_Mailer {
             'body' => $parts[2]
         );
     }
-    function send()
+    function send($email = false)
     {
         
-        $email = $this->toData();
+        $pg = HTML_FlexyFramework::get()->page;
+        
+        
+        $email = is_array($email)  ? $email : $this->toData();
         if (is_a($email, 'PEAR_Error')) {
+            $pg->addEvent("COREMAILER-FAIL",  false, "email toData failed"); 
+      
+            
             return $email;
         }
         if ($this->debug) {
@@ -270,8 +277,11 @@ class Pman_Core_Mailer {
         $mailOptions = PEAR::getStaticProperty('Mail','options');
         //print_R($mailOptions);exit;
         $mail = Mail::factory("SMTP",$mailOptions);
-        $headers['Date'] = date('r'); 
+        $email['headers']['Date'] = date('r'); 
         if (PEAR::isError($mail)) {
+             $pg->addEvent("COREMAILER-FAIL",  false, "mail factory failed"); 
+      
+            
             return $mail;
         } 
         $rcpts = $this->rcpts == false ? $email['recipents'] : $this->rcpts;
@@ -283,6 +293,12 @@ class Pman_Core_Mailer {
         $oe = error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT);
         $ret = $mail->send($rcpts,$email['headers'],$email['body']);
         error_reporting($oe);
+        if ($ret === true) { 
+            $pg->addEvent("COREMAILER-SENT",  false,
+                'To: ' .  ( is_array($rcpts) ? implode(', ', $rcpts) : $rcpts ) .
+                'Subject: '  . @$email['headers']['Subject']
+            ); 
+        }  
        
         return $ret;
     }