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.

FAQ
  • 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 mailer-2.2.zip
Resources

Documentation

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

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

<?php
$message = 'Hello World!';
$mailer = Yii::createComponent('application.extensions.mailer.EMailer');
$mailer->Host = <your smtp host>;
$mailer->IsSMTP();
$mailer->From = 'wei@example.com';
$mailer->AddReplyTo('wei@example.com');
$mailer->AddAddress('qiang@example.com');
$mailer->FromName = 'Wei Yard';
$mailer->CharSet = 'UTF-8';
$mailer->Subject = Yii::t('demo', 'Yii rulez!');
$mailer->Body = $message;
$mailer->Send();
As an application component:

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

<?php
'components'=>array(
   'mailer' => array(
      'class' => 'application.extensions.mailer.EMailer',
      'pathViews' => 'application.views.email',
      'pathLayouts' => 'application.views.email.layouts'
   ),
   // ...
}

In the controller:

<?php
$message = 'Hello World!';
Yii::app()->mailer->Host = 'smtp.yiiframework.com';
Yii::app()->mailer->IsSMTP();
Yii::app()->mailer->From = 'wei@pradosoft.com';
Yii::app()->mailer->FromName = 'Wei';
Yii::app()->mailer->AddReplyTo('wei@pradosoft.com');
Yii::app()->mailer->AddAddress('qian@yiiframework.com');
Yii::app()->mailer->Subject = 'Yii rulez!';
Yii::app()->mailer->Body = $message;
Yii::app()->mailer->Send();

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
70 followers
22 987 downloads
Yii Version: 1.1
License: LGPL-3.0
Category: Mail
Tags:
Developed by: MetaYii
Created on: Nov 19, 2008
Last updated: 12 years ago

Downloads

show all