mailer Mailer using PHPMailer

  1. Documentation
  2. Change Log

EMailer is a simple wrapper for the PHPMailer library, which is bundled. You should keep an eye on this library, since it could be updated and the API could get broken.

Please read the source code comments for licensing information. Please read the phpmailer/LICENCE file for the PHPMailer license.

  • Why should I use this extension instead of using the phpmailer directly?

Answer: this is encapsulated as a Yii extension, and you can modify the methods or extend the functionality as you'd like, instead of modifying the original source code :)

  • Why the license was GPL on the download page when the extension is released under LGPL?

Answer: my mistake. The license for this extension is and has always been LGPL.

  • My view has images on it, but when it is send as e-mail, no images are shown. Why?

You must place the images in a public HTTP server, since you're using the tag in your view.

File checksums
  • 847183726a2e59d8aa5968e2fa6f7597 mailer-2.2.tar.bz2
  • bef73d62003ab84399706c578294cccb


  • Yii 1.0 or above
  • PHPMailer (version 5.0 bundled)
  • Extract the release file under protected/extensions
As a normal component:

Usage example, using SMTP as the sending method, creating a component inside a controller:

$message = 'Hello World!';
$mailer = Yii::createComponent('application.extensions.mailer.EMailer');
$mailer->Host = <your smtp host>;
$mailer->From = '';
$mailer->FromName = 'Wei Yard';
$mailer->CharSet = 'UTF-8';
$mailer->Subject = Yii::t('demo', 'Yii rulez!');
$mailer->Body = $message;
As an application component:

In the configuration (notice the pathViews and pathLayouts parameters):

   'mailer' => array(
      'class' => 'application.extensions.mailer.EMailer',
      'pathViews' => '',
      'pathLayouts' => ''
   // ...

In the controller:

$message = 'Hello World!';
Yii::app()->mailer->Host = '';
Yii::app()->mailer->From = '';
Yii::app()->mailer->FromName = 'Wei';
Yii::app()->mailer->Subject = 'Yii rulez!';
Yii::app()->mailer->Body = $message;

Since this is a wrapper, please see:

Change Log

20090529 2.2
  • Fixed bug (reported by ooaat)
20090516 2.1
  • Added pathViews and pathLayouts configuration parameters, to indicate a path aliases where the view and layout for getView are.
  • Added an empty init() method to make it work as an application component.
20090411 2.0
  • Updated PHPMailer to version 5.0
  • Included getView method.
55 1
22 987 downloads
Yii Version: 1.1
License: LGPL-3.0
Category: Mail
Developed by: MetaYii
Created on: Nov 19, 2008
Last updated: 12 years ago


show all