Giter VIP home page Giter VIP logo

laravel-mailjet-driver's Introduction

Laravel Mailjet Driver

Build Status Packagist Packagist License

Laravel mail driver package for Mailjet. It also serves as a wrapper for Mailjet API v3.

Installation

First, include the package in your dependencies:

composer require thedoctor0/laravel-mailjet-driver

If you are using Laravel before version 5.5 that supports Package Auto-Discovery, you need to add provider and alias manually to config/app.php.

  • In the providers array:
'providers' => [
    ...
    Mailjet\LaravelMailjet\MailjetServiceProvider::class,
    Mailjet\LaravelMailjet\MailjetMailServiceProvider::class,
    ...
]
  • In the aliases array:
'aliases' => [
    ...
    'Mailjet' => Mailjet\LaravelMailjet\Facades\Mailjet::class,
    ...
]

Configuration

You can find your Mailjet API key / secret here.

Change default mail driver and add new variables to your .env file:

MAIL_DRIVER=mailjet

MAILJET_APIKEY=YOUR_APIKEY
MAILJET_APISECRET=YOUR_APISECRET

Add section to the config/services.php file:

'mailjet' => [
    'key' => env('MAILJET_APIKEY'),
    'secret' => env('MAILJET_APISECRET'),
],

Make sure that in config/mail.php as mail sender address you are using a authorised email address configured on your Mailjet account.

Your available Mailjet email addresses and domains can be managed here.

For Laravel 7+ you also need to specify new available mail driver in config/mail.php:

'mailers' => [
    ...

    'mailjet' => [
        'transport' => 'mailjet',
    ],
],

Optional configuration

You can add full configuration for MailjetClient to the config/services.php file.

  • transactional: settings to sendAPI client
  • common: setting to MailjetClient accessible throught the Facade Mailjet
'mailjet' => [
    'key' => env('MAILJET_APIKEY'),
    'secret' => env('MAILJET_APISECRET'),
    'transactional' => [
        'call' => true,
        'options' => [
            'url' => 'api.mailjet.com',
            'version' => 'v3.1',
            'call' => true,
            'secured' => true
        ],
    ],
    'common' => [
        'call' => true,
        'options' => [
            'url' => 'api.mailjet.com',
            'version' => 'v3',
            'call' => true,
            'secured' => true
        ],
    ],
],

API Wrapper usage

In order to API wrapper from this package, you first need to import Mailjet Facade in your code:

use Mailjet\LaravelMailjet\Facades\Mailjet;

Then you can use one of the methods available in the MailjetServices class.

Low level API methods:

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

High level API methods:

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

All method return Mailjet\Response or throw a MailjetException in case of any API error.

You can also get the Mailjet API client with the method getClient() and make your own custom request to Mailjet API.

For more information please refer to the official Mailjet API documentation.

laravel-mailjet-driver's People

Contributors

thedoctor0 avatar nightbr avatar skalero01 avatar mskochev avatar mitomitov avatar dependabot-preview[bot] avatar arnaudbreton avatar latanasov avatar simonschaufi avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.