Skip to content

RobIsHere/laravel-mailjet

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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('[email protected]')->to('[email protected]')->subject('Testing mailjet');
    });
    
    return dd($mail);
});

About

Mailjet wrapper for Laravel

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%