1. Go to this page and download the library: Download jlorente/yii2-brevo library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jlorente / yii2-brevo example snippets
...
'components' => [
// ... other configurations ...
'mailer' => [
'class' => \jlorente\brevo\Mailer::class,
'apiKey' => env('BREVO_API_KEY'),
'defaultSender' => [
'email' => '[email protected]',
'name' => 'My App',
],
'sandboxEmail' => '[email protected]', // or an array of addresses
'guzzleConfig' => [
'timeout' => 10.0,
// add proxy or other Guzzle options if needed
],
'useFileTransport' => false,
'viewPath' => '@app/mail',
],
],
...
Yii::$app->mailer->compose()
->setTo('[email protected]')
->setSubject('Hello from Brevo')
->setHtmlBody('<h1>Hello</h1><p>HTML body</p>')
->setTextBody('Hello — plain text body')
->send();