This extension provides a Mailgun mail solution for Yii framework 2.0.
The preferred way to install this extension is through composer.
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.
If you just want to get started quickly you should install Buzz and nyholm/psr7:
composer require kriswallsmith/buzz nyholm/psr7To use this extension, simply add the following code in your application configuration:
return [
//....
'components' => [
'mailer' => [
'class' => 'boundstate\mailgun\Mailer',
'key' => 'key-example',
'domain' => 'mg.example.com',
],
],
];You can then send an email as follows:
Yii::$app->mailer->compose('contact/html', ['contactForm' => $form])
->setFrom('from@domain.com')
->setTo($form->email)
->setSubject($form->subject)
->send();For further instructions refer to the related section in the Yii Definitive Guide.