2017 © Pedro Peláez
 

yii2-extension yii2-mailer

Mailer for Yii2

image

tecsvit/yii2-mailer

Mailer for Yii2

  • Friday, October 27, 2017
  • by fa2mm
  • Repository
  • 1 Watchers
  • 0 Stars
  • 18 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 20 % Grown

The README.md

Mailer

Mailer for Yii2, (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

php composer.phar require --prefer-dist tecsvit/yii2-mailer "*"

or (dev), (*4)

composer require --prefer-dist tecsvit/yii2-mailer "@dev"

or add, (*5)

"tecsvit/yii2-mailer": "*"

to the require section of your composer.json file., (*6)

Usage

Once the extension is installed, simply use it in your code by :, (*7)

...
'components' => [
        ...
        'mailer' => [
            'class' => '\tecsvit\mailer\components\Mailer',
            'useFileTransport'      => false,
            'defaultTemplates'      => [
                'YOUR_NAME_TEMPLATE'   => [
                    'subject'       => 'Your_mail_subject',
                    'template'      => 'Your_template_filename',
                    'senderMail'    => 'Sender_Email',
                    'senderName'    => 'Sender_Name',
                ],
            ],
            'transport' => [
                'class'         => 'Swift_SmtpTransport',
                'host'          => 'your_host',
                'username'      => 'your_username',
                'password'      => 'your_pass',
                'port'          => 'your_port',
                'encryption'    => 'your_encryption',
            ],
        ],
        ...

Example:, (*8)

...
'components' => [
        ...
        'mailer' => [
            'class' => '\tecsvit\mailer\components\Mailer',
            'useFileTransport'      => false,
            'defaultTemplates'      => [
                'confirmPassword'   => [
                    'subject'       => 'Hi',
                    'template'      => 'confirmPassword.php',
                    'senderMail'    => 'admin@admin.com',
                    'senderName'    => 'Admin',
                ],
                'subscribe'   => [
                    'subject'       => 'Hi2',
                    'template'      => 'subscribe.php',
                    'senderMail'    => 'subscribe@admin.com',
                    'senderName'    => 'Manager',
                ],
            ],
            'transport' => [
                'class'         => 'Swift_SmtpTransport',
                'host'          => 'smtp.gmail.com',
                'username'      => 'user@gmail.com',
                'password'      => '4565456464',
                'port'          => '587',
                'encryption'    => 'tls',
            ],
        ],
        ...

Create template(s) in directory ../app/mail/ (example):, (*9)

confirmPassword.php, (*10)

<strong>Confirm Your Mail</strong>
<div>
    For confirm your mail click on link: <a href="http://site.com/user/confirm-email?hash=<?= $hash ?>">click</a>
</div>

In your code, (*11)

    $toMail = 'mail-your-friend@gmail.com';
    $data = ['hash' => $hash];
    /** @var \tecsvit\mailer\components\Mailer $mailer */
    $mailer = Yii::$app->mailer;
    $mailer->sendMail($toMail, $data, 'confirmPassword');

The Versions

27/10 2017

dev-master

9999999-dev

Mailer for Yii2

  Sources   Download

Apache-2.0

The Requires

 

by Tecsvit

extension yii2 mailer

27/10 2017

1.0.0

1.0.0.0

Mailer for Yii2

  Sources   Download

Apache-2.0

The Requires

 

by Tecsvit

extension yii2 mailer