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 mailer-2.2.zip
- Yii 1.0 or above
- PHPMailer (version 5.0 bundled)
- Extract the release file under
As a normal component: ¶
Usage example, using SMTP as the sending method, creating a component inside a controller:
'Hello World!'; $mailer = Yii::createComponent('application.extensions.mailer.EMailer'); $mailer->Host = <your smtp host>; $mailer->IsSMTP(); $mailer->From = 'firstname.lastname@example.org'; $mailer->AddReplyTo('email@example.com'); $mailer->AddAddress('firstname.lastname@example.org'); $mailer->FromName = 'Wei Yard'; $mailer->CharSet = 'UTF-8'; $mailer->Subject = Yii::t('demo', 'Yii rulez!'); $mailer->Body = $message; $mailer->Send();$message =
As an application component: ¶
In the configuration (notice the pathViews and pathLayouts parameters):
'components'=>array( 'mailer' => array( 'class' => 'application.extensions.mailer.EMailer', 'pathViews' => 'application.views.email', 'pathLayouts' => 'application.views.email.layouts' ), // ... }
In the controller:
'Hello World!'; Yii::app()->mailer->Host = 'smtp.yiiframework.com'; Yii::app()->mailer->IsSMTP(); Yii::app()->mailer->From = 'email@example.com'; Yii::app()->mailer->FromName = 'Wei'; Yii::app()->mailer->AddReplyTo('firstname.lastname@example.org'); Yii::app()->mailer->AddAddress('email@example.com'); Yii::app()->mailer->Subject = 'Yii rulez!'; Yii::app()->mailer->Body = $message; Yii::app()->mailer->Send();$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.