siallez / laravel-mailjet by siallez

Mailjet wrapper for Laravel
85
5
3
Package Data
Maintainer Username: siallez
Package Create Date: 2015-12-06
Package Last Update: 2016-03-19
Language: PHP
License: MIT
Last Refreshed: 2021-01-13 03:00:34
Package Statistics
Total Downloads: 85
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 5
Total Watchers: 3
Total Forks: 8
Total Open Issues: 1

Mailjet for Laravel

This package integrates the Mailjet API Client in Laravel. You can access the API through Laravel service container or sending mails in Laravel's way with the new driver.

Install

This package requires version 5.1 of Laravel framework. I can't ensure the compatibility with other versions.

In your composer.json, add this to the require section:

"siallez/laravel-mailjet" : "dev-master",

Run composer update.

In config/app.php, add this to the providers array:

Siallez\Mailjet\MailjetServiceProvider::class,

Setup

In order to start using the package you only need to add these environment variables in your .env file with your Mailjet keys:

MAILJET_APIKEY_PUBLIC=
MAILJET_APIKEY_PRIVATE=

If you want to use the driver you should also add this:

MAIL_DRIVER=mailjet

Usage

You can access the API with dependency injection or all other available methods to resolve the Service Container. If you want to learn how to use it you can go to the official Mailjet repository.

Example:

Route::get('/mailjet', function(\Mailjet\Client $mj) {
    $response = $mj->get(\Mailjet\Resources::$Contact);
    if ($response->success()) {
        $contact = $response->getData();
        return dd($contact);
    }

    return dd($response);
});

Using the driver is as easy as setting mailjet as the mail driver (look at Setup). After that, you can use the regular Laravel's Mail facade and all mails will be sent with mailjet. You can find all the information about that here.

Example:

Route::get('/mailjet2', function() {
    $mail = Mail::raw('Text to e-mail', function ($message) {
        $message->from('from@email.com')->to('to@email.com')->subject('Testing mailjet');
    });
    
    return dd($mail);
});