Skip to content
World Wide Web Server edited this page Jul 4, 2012 · 32 revisions

Category:Libraries

[b]Code Igniter Richmail Library version 0.1[/b]

By Jan Willem Penterman [email protected] (Genoil on codeigniter.com) September 29, 2006

File:richmail-0.1.zip

[b]Features:[/b]

This library extends the Email library, adding the following functions:

  • parse message body for images and add them as inline attachments
  • caches base64 encoded attachments for better performance

[b]Installation:[/b]

The directories inside this archive should look familiar enough to you to know where to put the files...

[b]Usage example:[/b] [code] ; // Load Richmail library instead of 'email': $this->load->library('richmail');

// Since it subclasses CI_Email, this is all the same: $this->richmail->from('[email protected]', 'Sender'); $this->richmail->to('[email protected]', 'Recipient');
$this->richmail->subject('Richmail test');

// Load message like any CI view: $message = $this->load->view("richmail_view", array(), true);

// Convert message to have images reference inline content-id's. // $message is passed by reference, but is also returned if you // don't understand what I'm talking about.
$this->richmail->inline($message);

// This is like Email again: $this->richmail->message($message); $this->richmail->send(); [/code]

[b]Notes:[/b]

  • Currently, only HTML image references are supported, no CSS. This is
    because inline CSS background images aren't supported very well in HTML email anyway.

  • The library assumes the host that serves the images is equal to the CI's base_url config var.

  • Base64 caching speeds up attachment building about 2 times, but I'm not too happy about having to duplicate the whole Email::_build_message() method.

  • It does not currently appear to support two inline images with the same name correctly - solve this by making sure all images have unique filenames.

[h3]Updated to work with CodeIgniter 1.5.3[/h3] This is the same class updated to work with Code Igniter 1.5.3 File:MY_Email.php.

Just drop it into the /application/libraries directory and use as you would use the email class.

[code] $this->load->library('email'); $email_config = array ( 'mailtype' => 'html', 'multipart' => 'related', 'base64cache' => false ); $this->email->initialize($email_config);

// Since it subclasses CI_Email, this is all the same: $this->email->from('[email protected]', 'Your Name'); $this->email->to('[email protected]'); $this->email->cc('[email protected]'); $this->email->bcc('[email protected]'); $this->email->subject('Email Test');

// Load message like any CI view: $email_message = $this->load->view("email_message.html", array(), true);

// Convert message to have images reference inline content-id's. $this->email->inline($email_message);

// This is like Email again: $this->email->message($email_message); $this->email->send(); [/code]

Clone this wiki locally