PHP code example of eubourne / laravel-mailgun

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

    

eubourne / laravel-mailgun example snippets

  
'mailgun-api' => [
    'secret' => env('MAILGUN_SECRET'),
    'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
],

'mailgun-tx' => [
    'transport' => env('MAIL_TX_TRANSPORT', 'mailgun-api'),
    'from' => [
        'address' => env('MAIL_TX_FROM_ADDRESS', env('MAIL_FROM_ADDRESS')),
        'name' => env('MAIL_FROM_NAME')
    ],
    'domain' => env('MAILGUN_DOMAIN'),
    'logger' => env('MAIL_LOG_CHANNEL'),
],

Mail::mailer('mailgun-tx')->to($user)->send(new OrderShipped($order));

class OrderPlaced extends Mailable
{
    public $mailer = 'transactional';
    ...
}

$mailable = new OrderPlaced();
$mailable->mailer('transactional');
Mail::to($user)->send($mailable);

$mailable = new OrderPlaced();
$mailable->mailer('transactional');
Mail::mailer('promotional')->to($user)->send($mailable);

'whitelist' => ['[email protected]']
bash
php artisan mail:test {email}
bash
php artisan mail:test [email protected]
bash
php artisan mail:test [email protected] --mailer=mailgun-tx
bash
php artisan mail:test [email protected] --queue=mail