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

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

tikaraj21/yii2-mailer
=====================

mailer

012PHP

Since Dec 30Pushed 9y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)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 tikaraj21/yii2-mailer "*"

```

or add

```
"tikaraj21/yii2-mailer": "*"

```

if any problem use "yiisoft/yii2-swiftmailer": "~2.0.5", 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' => 'tikaraj21\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

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

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

---

Top Contributors

[![tikaraj21](https://avatars.githubusercontent.com/u/12813067?v=4)](https://github.com/tikaraj21 "tikaraj21 (5 commits)")

### Embed Badge

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

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

###  Alternatives

[tijsverkoyen/css-to-inline-styles

CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very useful when you're sending emails.

5.8k505.3M227](/packages/tijsverkoyen-css-to-inline-styles)[minishlink/web-push

Web Push library for PHP

1.9k12.0M53](/packages/minishlink-web-push)[laravel-notification-channels/twilio

Provides Twilio notification channel for Laravel

2587.7M12](/packages/laravel-notification-channels-twilio)[spatie/url-signer

Generate a url with an expiration date and signature to prevent unauthorized access

4422.3M16](/packages/spatie-url-signer)[mattketmo/email-checker

Throwaway email detection library

2742.0M5](/packages/mattketmo-email-checker)[laravel-notification-channels/discord

Laravel notification driver for Discord.

2371.3M11](/packages/laravel-notification-channels-discord)

PHPackages © 2026

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