PHPackages                             stevad/yiimailer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. stevad/yiimailer

AbandonedArchivedLibrary[Mail &amp; Notifications](/categories/mail)

stevad/yiimailer
================

Yii extension for sending emails with layouts using PHPMailer

1.2(8y ago)05.9kPHPPHP &gt;=5.5.0

Since Feb 17Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/Stevad/YiiMailer)[ Packagist](https://packagist.org/packages/stevad/yiimailer)[ RSS](/packages/stevad-yiimailer/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (1)Versions (4)Used By (0)

YiiMailer
=========

[](#yiimailer)

Warning

This repository is not maintained anymore!

Yii extension for sending emails with layouts using [PHPMailer](https://github.com/PHPMailer/PHPMailer)

Features
--------

[](#features)

- Based on latest PHPMailer (version 5.2.x branch)
- Supports Yii layouts and translation
- Supports web and console applications
- Send full HTML emails with embedded images
- Work with views like you usually do in Yii
- Use test mode to save emails instead of sending them (useful when you don't have mail server installed locally)

Installation
------------

[](#installation)

1. Copy YiiMailer folder to protected/extensions
2. Add 'ext.YiiMailer.YiiMailer' line to your imports in main and/or console yii config
3. Copy mail.php config file to protected/config or add configuration array in 'params' under the key 'YiiMailer'
4. Create email layout file mail.php in protected/views/layouts/ (default path, can be changed in config)
5. Create all the views you want to use in protected/views/mail/ (default path, can be changed in config)
6. Put all images you want to embed in emails in images/mail/ (default path, can be changed in config)

Usage
-----

[](#usage)

Instantiate YiiMailer in your controller or console command and pass view and data array:

```
$mail = new YiiMailer('contact', array('message' => 'Message to send', 'name' => 'John Doe', 'description' => 'Contact form'));
```

or

```
$mail = new YiiMailer();
$mail->setView('contact');
$mail->setData(array('message' => 'Message to send', 'name' => 'John Doe', 'description' => 'Contact form'));
```

Layout is automatically set from config but you may override it with

```
$mail->setLayout('layoutName');
```

Set the properties:

```
$mail->setFrom('from@example.com', 'John Doe');
$mail->setTo(Yii::app()->params['adminEmail']);
$mail->setSubject('Mail subject');
```

You may use all PHPMailer properties you would usually use.

And finally send email(s):

```
if ($mail->send()) {
	Yii::app()->user->setFlash('contact','Thank you for contacting us. We will respond to you as soon as possible.');
} else {
	Yii::app()->user->setFlash('error','Error while sending email: '.$mail->getError());
}
```

### Sending simple messages

[](#sending-simple-messages)

You can send email without both the layout and view by using:

```
$mail = new YiiMailer();
//$mail->clearLayout();//if layout is already set in config
$mail->setFrom('from@example.com', 'John Doe');
$mail->setTo(Yii::app()->params['adminEmail']);
$mail->setSubject('Mail subject');
$mail->setBody('Simple message');
$mail->send();
```

Alternatively, you may also send email message with layout but without specific view (set layout and set body) or with view but without layout (clear layout and set view).

### Setting addresses

[](#setting-addresses)

When using methods for setting addresses (setTo(), setCc(), setBcc(), setReplyTo()) any of the following is valid for arguments:

```
$mail->setTo('john@example.com');
$mail->setTo(array('john@example.com','jane@example.com'));
$mail->setTo(array('john@example.com'=>'John Doe','jane@example.com'));
```

### Sending attachments

[](#sending-attachments)

You may send one or more attachments using setAttachemnt() method:

```
$mail->setAttachment('something.pdf');
$mail->setAttachment(array('something.pdf','something_else.pdf','another.doc'));
$mail->setAttachment(array('something.pdf'=>'Some file','something_else.pdf'=>'Another file'));
```

### Test mode

[](#test-mode)

When working locally without mail server installed, it may be useful to save emails as files instead of trying to send them and getting errors in the process. To use test mode, you must specify path to directory where you want to save your emails and set 'testMode' property to 'true' in your config:

```
	'savePath' => 'webroot.assets.mail',
	'testMode' => true,
```

Emails are saved as .eml files and you can use software like Mozilla Thunderbird to open them.

Examples
--------

[](#examples)

Two examples included: one for standard contact form in yii web app and the other one for yii console app.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance41

Moderate activity, may be stable

Popularity17

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~645 days

Total

3

Last Release

3226d ago

PHP version history (2 changes)1.0.0PHP &gt;=5.0.0

1.1PHP &gt;=5.5.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/f8874a1d687c77b4b59c503982537fc5fe00c5d67ab00451217c57d70bd587da?d=identicon)[Stevad](/maintainers/Stevad)

---

Top Contributors

[![vernes](https://avatars.githubusercontent.com/u/973728?v=4)](https://github.com/vernes "vernes (6 commits)")[![Stevad](https://avatars.githubusercontent.com/u/9192085?v=4)](https://github.com/Stevad "Stevad (3 commits)")[![dmitrivereshchagin](https://avatars.githubusercontent.com/u/14558877?v=4)](https://github.com/dmitrivereshchagin "dmitrivereshchagin (2 commits)")[![RdeWilde](https://avatars.githubusercontent.com/u/184016?v=4)](https://github.com/RdeWilde "RdeWilde (2 commits)")

### Embed Badge

![Health badge](/badges/stevad-yiimailer/health.svg)

```
[![Health](https://phpackages.com/badges/stevad-yiimailer/health.svg)](https://phpackages.com/packages/stevad-yiimailer)
```

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[getkirby/cms

The Kirby core

1.5k567.4k436](/packages/getkirby-cms)[ivantcholakov/codeigniter-phpmailer

A CodeIgniter 3 compatible email-library powered by PHPMailer.

25214.2k](/packages/ivantcholakov-codeigniter-phpmailer)[vernes/yiimailer

Yii extension for sending emails with layouts using PHPMailer

81121.5k](/packages/vernes-yiimailer)[nfephp-org/sped-mail

API para geração e envio dos emails relacionados com o SPED.

1126.1k](/packages/nfephp-org-sped-mail)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
