dmitxe/yii2-mailgun

Mailgun integration for the Yii framework

Installs: 31

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:yii2-extension

dev-master 2020-06-25 21:11 UTC

This package is auto-updated.

Last update: 2021-05-25 23:38:42 UTC


README

Mailgun integration for the Yii framework. This is fork boundstate/yii2-mailgun

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist dmitxe/yii2-mailgun "*"

or add

"dmitxe/yii2-mailgun": "*"

to the require section of your composer.json file.

Usage

Configure it in the application configuration:

'components' => [
    ...
    'mailer' => [
        'class' => 'dmitxe\mailgun\Mailer',
        'key' => 'key-example',
        'domain' => 'mg.example.com',
        'endpoint' => 'https://api.mailgun.net',
    ],
    ...
],

To send an email, you may use the following code:

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