PHPackages                             samsher-bentray/yii2-mailer - 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. samsher-bentray/yii2-mailer

ActiveYii2-extension[Mail &amp; Notifications](/categories/mail)

samsher-bentray/yii2-mailer
===========================

PHP and SMTP Mailer

v0.0.3(10y ago)1581BSD-2-ClausePHP

Since Dec 28Pushed 10y ago1 watchersCompare

[ Source](https://github.com/samsher-bentray/yii2-mailer)[ Packagist](https://packagist.org/packages/samsher-bentray/yii2-mailer)[ RSS](/packages/samsher-bentray-yii2-mailer/feed)WikiDiscussions master Synced 1mo ago

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

Mailer
======

[](#mailer)

PHP and SMTP Mailer in Yii2 with dynamic configuration

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist samsher-bentray/yii2-mailer "*"

```

or add

```
"samsher-bentray/yii2-mailer": "*"

```

to the require section of your `composer.json` file.

Configuration
-------------

[](#configuration)

Once the extension is installed, add following code to your application configuration :

```
return [
    //....
    'components' => [

            ...

            'email' => 'samsher\mailer\Mail',

            ...

    ],
];
```

Usage
-----

[](#usage)

Once the extension is installed, simply use it in your code by using these codes as following way in the controller:

```
public function actionCreate()

    {

        $model = new Email();

        if ($model->load(Yii::$app->request->post())) {

                /*Starting configuration for smtp or other type*/

                Yii::$app->email->setMailType('SMTP');//aeruement is either 'SMTP' or 'PHPMAIL'

                //Passing arguement for Host setting
                Yii::$app->email->setHost('smtp.gmail.com');// aeruement is 'smtp.gmail.com' for gmail

                //Passing arguement for Username setting
                Yii::$app->email->setUname('some email');

                //Passing arguement for Password setting
                Yii::$app->email->setPassd('password');

                //Passing arguement for Encryption Type setting
                Yii::$app->email->setEncType('ssl');//encryption type must either be 'ssl' or 'tls'

                //Passing arguement for Port setting
                Yii::$app->email->setServerPort('465'); port of gmail server is '465' for 'SSL' and '587' for 'TLS'

                /*Ending configuration for smtp or other type*/
                Yii::$app->email->configSet();//note that email setting is completed only after executing this function

                /*Starting configuration for php mail*/

                //Passing arguement to set from
                Yii::$app->email->setFrom('some email');

                //Passing arguement to set Reply To
                Yii::$app->email->setReplyTo('some email');

                //Passing arguement to set Return Path
                Yii::$app->email->setReturnPath('some email');

                $to = $model->to;

                $subject = $model->subject;

                $message_body = $model->text_body;

                $cc = $model->cc;

                $bcc = $model->bcc;

                /*Assigning the files for attachments*/

                $attachment = UploadedFile::getInstances($model,'attachment');

				Yii::$app->email->SaveAttach($attachment);

                // Syntax Yii::$app->email->SendMail($from,$to,$subject,$message_body,$cc,$bcc,$attachment);
                // It is important that default mail type is PHP mail
                // If we want to use PHP mail ,we can call only the function
                // "Yii::$app->email->SendMail($from,$to,$subject,$message_body,$cc,$bcc,$attachment);"
                // If we want to use Smtp mail or other type, we can call the function
                // "Yii::$app->email->SendMail($from,$to,$subject,$message_body,$cc,$bcc,$attachment);"
                // only after the six setting for and running Yii::$app->email->configSet();

               if (Yii::$app->email->SendMail($from,$to,$subject,$message_body,$cc,$bcc,$attachment)){

					//deleting the attachment
					Yii::$app->email->DeleteAttach($attachments);
                    Yii::$app->session->setFlash('success','Email sent.'); //for for wrong event.
                    return $this->redirect(['create']);
                }
                else {
                    Yii::$app->session->setFlash('danger','Email send not success.'); //for for wrong event.
                    return $this->redirect(['create']);
                }
        }

        else{

            return $this->render('create', [

                'model' => $model,

            ]);

        }

    }
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~16 days

Total

3

Last Release

3757d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5323b857144967056137fe9da58740352b88f31ada29d255f74c8a376b61b74e?d=identicon)[samsher-bentray](/maintainers/samsher-bentray)

---

Top Contributors

[![samsher-bentray](https://avatars.githubusercontent.com/u/13114549?v=4)](https://github.com/samsher-bentray "samsher-bentray (27 commits)")

---

Tags

yii2extension

### Embed Badge

![Health badge](/badges/samsher-bentray-yii2-mailer/health.svg)

```
[![Health](https://phpackages.com/badges/samsher-bentray-yii2-mailer/health.svg)](https://phpackages.com/packages/samsher-bentray-yii2-mailer)
```

###  Alternatives

[nterms/yii2-mailqueue

Email queue component for yii2 that works with yii2-swiftmailer.

87129.2k2](/packages/nterms-yii2-mailqueue)[nickcv/yii2-mandrill

Mandrill Api Integration for Yii2

29554.2k2](/packages/nickcv-yii2-mandrill)[odaialali/yii2-toastr

This is the Toastr extension for Yii 2. It encapsulates Toastr plugin in terms of Yii widgets, and makes ajax notification easy to implement.

1486.3k](/packages/odaialali-yii2-toastr)

PHPackages © 2026

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