[limb-svn] r6865 - 3.x/trunk/limb/mail/src

svn at limb-project.com svn at limb-project.com
Fri Mar 28 13:47:33 MSK 2008


Author: svk
Date: 2008-03-28 13:47:33 +0300 (Fri, 28 Mar 2008)
New Revision: 6865
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6865

Modified:
   3.x/trunk/limb/mail/src/lmbMailer.class.php
Log:
-- ability to send letters with embedded images added

Modified: 3.x/trunk/limb/mail/src/lmbMailer.class.php
===================================================================
--- 3.x/trunk/limb/mail/src/lmbMailer.class.php	2008-03-28 10:40:16 UTC (rev 6864)
+++ 3.x/trunk/limb/mail/src/lmbMailer.class.php	2008-03-28 10:47:33 UTC (rev 6865)
@@ -23,6 +23,7 @@
 class lmbMailer
 {
   protected $attachments = array();
+  protected $images = array();
 
   protected $_config_properties_map = array(
     'phpmailer_dir' => 'PHPMAILER_DIR',
@@ -95,6 +96,17 @@
       'type' => $type
     );
   }
+  
+  function embedImage($path, $cid, $name="", $encoding="base64", $type="application/octet-stream")
+  {
+    $this->images[] = array(
+      'path' => $path,
+      'cid' => $cid,
+      'name' => $name,
+      'encoding' => $encoding,
+      'type' => $type
+    );
+  }
 
   function sendPlainMail($recipients, $sender, $subject, $body, $charset = 'utf-8')
   {
@@ -106,6 +118,9 @@
     if(!empty($this->attachments))
       $this->_addAttachments($mailer);
 
+    if(!empty($this->images))
+      $this->_addEmbeddedImages($mailer);
+      
     $recipients = $this->processMailRecipients($recipients);
 
     foreach($recipients as $recipient)
@@ -134,6 +149,9 @@
     if(!empty($this->attachments))
       $this->_addAttachments($mailer);
 
+    if(!empty($this->images))
+      $this->_addEmbeddedImages($mailer);
+      
     if(!is_null($text))
       $mailer->AltBody = $text;
 
@@ -189,4 +207,16 @@
                              $attachment['encoding'],
                              $attachment['type']);
   }
+  
+  protected function _addEmbeddedImages($mailer)
+  {
+    foreach ($this->images as $image)
+    {
+      $mailer->AddEmbeddedImage($image['path'],
+                                $image['cid'],
+                                $image['name'],
+                                $image['encoding'],
+                                $image['type']);
+    }
+  }
 }



More information about the limb-svn mailing list