2017 © Pedro Peláez
 

yii2-extension yii2-mailgun

Mailgun integration for the Yii framework

image

boundstate/yii2-mailgun

Mailgun integration for the Yii framework

  • Friday, May 13, 2016
  • by mikejpeters
  • Repository
  • 8 Watchers
  • 18 Stars
  • 9,925 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 24 Forks
  • 5 Open issues
  • 4 Versions
  • 12 % Grown

The README.md

Mailgun Extension for Yii 2

This extension provides a Mailgun mail solution for Yii framework 2.0., (*1)

Latest Stable Version Total Downloads Build Status, (*2)

Installation

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

composer require boundstate/yii2-mailgun

The Mailgun API Client is not hard coupled to Guzzle, Buzz or any other library that sends HTTP messages. You must also install the PSR-7 implementation and HTTP client you want to use., (*4)

If you just want to get started quickly you should install Buzz and nyholm/psr7:, (*5)

composer require kriswallsmith/buzz nyholm/psr7

Usage

To use this extension, simply add the following code in your application configuration:, (*6)

return [
    //....
    'components' => [
        'mailer' => [
            'class' => 'boundstate\mailgun\Mailer',
            'key' => 'key-example',
            'domain' => 'mg.example.com',
        ],
    ],
];

You can then send an email as follows:, (*7)

Yii::$app->mailer->compose('contact/html', ['contactForm' => $form])
    ->setFrom('from@domain.com')
    ->setTo($form->email)
    ->setSubject($form->subject)
    ->send();

You can also specify an array of addresses and/or speicfy names:, (*8)

$message->setTo(['bob@example.com' => 'Bob']);

Warning: By default all recipients' email address will show up in the to field for each recipient. Enable batch sending to avoid this., (*9)

Batch Sending

When batch sending is enabled, Mailgun sends each recipient an individual email with only their email in the to field., (*10)

To use batch sending, set the messageClass to boundstate\mailgun\BatchMessage in your application configuration:, (*11)

'mailer' => [
    'class' => 'boundstate\mailgun\Mailer',
    'messageClass' => 'boundstate\mailgun\BatchMessage',
    // ...
]

Composing a batch email is similar to regular emails, except you may define and use recipient variables:, (*12)

Yii::$app->mailer->compose('hello')
    ->setTo([
      'bob@example.com' => [
        'id': 3,
        'full_name' => 'Bob'
      ],
      'jane@example.com' => [
        'id': 4,
        'full_name' => 'Jane'
      ],
    ])
    ->setSubject('Hi %recipient.full_name%')
    ->send();

For further instructions refer to the Mailgun docs and the related section in the Yii Definitive Guide., (*13)

The Versions

13/05 2016

dev-master

9999999-dev

Mailgun integration for the Yii framework

  Sources   Download

Apache-2.0

The Requires

 

by Mike Peters

mail email extension yii2 mailer rackspace mailgun

13/05 2016

v0.0.3

0.0.3.0

Mailgun integration for the Yii framework

  Sources   Download

Apache-2.0

The Requires

 

by Mike Peters

mail email extension yii2 mailer rackspace mailgun

29/10 2015

v0.0.2

0.0.2.0

Mailgun integration for the Yii framework

  Sources   Download

Apache-2.0

The Requires

 

by Mike Peters

mail email extension yii2 mailer rackspace mailgun

12/05 2015

v0.0.1

0.0.1.0

Mailgun integration for the Yii framework

  Sources   Download

Apache-2.0

The Requires

 

by Mike Peters

mail email extension yii2 mailer rackspace mailgun