PHP code example of mailjet / laravel-mailjet

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

    

mailjet / laravel-mailjet example snippets


use Mailjet\LaravelMailjet\MailjetServiceProvider;

return [
    App\Providers\AppServiceProvider::class,
    MailjetServiceProvider::class,
];

'providers' => [
    // ...
    Mailjet\LaravelMailjet\MailjetServiceProvider::class,
],

'aliases' => [
    // ...
    'Mailjet' => Mailjet\LaravelMailjet\Facades\Mailjet::class,
],

'mailjet' => [
    'key'     => env('MAILJET_APIKEY'),
    'secret'  => env('MAILJET_APISECRET'),
    // filter_var keeps the "true"/"false" env string honest (handy in Docker)
    'sandbox' => filter_var(env('MAILJET_SANDBOX', false), FILTER_VALIDATE_BOOLEAN),
],

'mailers' => [
    // ...
    'mailjet' => [
        'transport' => 'mailjet',
    ],
],

use Illuminate\Support\Facades\Mail;

Mail::to($user)->send(new InvoicePaid($invoice));

use Mailjet\LaravelMailjet\Facades\Mailjet;

Mailjet::get($resource, $args, $options);
Mailjet::post($resource, $args, $options);
Mailjet::put($resource, $args, $options);
Mailjet::delete($resource, $args, $options);

Mailjet::getAllLists($filters);
Mailjet::createList($body);
Mailjet::getListRecipients($filters);
Mailjet::getSingleContact($id);
Mailjet::createContact($body);
Mailjet::createListRecipient($body);
Mailjet::editListrecipient($id, $body);

$client = Mailjet::getClient(); // the underlying \Mailjet\Client instance

// config/app.php
'providers' => [
    // ...
    Mailjet\LaravelMailjet\Providers\ContactsServiceProvider::class,
],

use Mailjet\LaravelMailjet\Services\ContactsV4Service;

public function handle(ContactsV4Service $contacts)
{
    $contacts->delete(351406781);
}