PHP code example of boundstate / yii2-mailgun

1. Go to this page and download the library: Download boundstate/yii2-mailgun 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/ */

    

boundstate / yii2-mailgun example snippets


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

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

$message->setTo(['[email protected]' => 'Bob']);

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

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