A Laravel wrapper for Elastic Email







Laravel Elastic Email

Donate Packagist Downloads GitHub CodeFactor Grade

A Laravel wrapper for sending emails via Elastic Email service and API capabilities that allows you to check the status of every email sent. It provides a basic email log table to store all outbound emails where you can link to a model.


Add Laravel Elastic Email as a dependency using the composer CLI:

composer require seinoxygen/laravel-elastic-email

Mail Service Usage

This package works exactly like Laravel's native mailers. Refer to Laravel's Mail documentation.

Add the following to your config/services.php and add the correct values to your .env file

'elastic_email' => [
	'key' => env('ELASTIC_KEY'),
	'account' => env('ELASTIC_ACCOUNT')

Add the following to your config/mail.php

'elastic_email' => [
	'transport' => 'elasticemail'

Next, in config/app.php, comment out Laravel's default MailServiceProvider. If using < Laravel 5.5, add the MailServiceProvider and ApiServiceProvider to the providers array

'providers' => [

Next, in config/app.php, add the ElasticEmail to the aliases array

'aliases' => [
    'ElasticEmail' => SeinOxygen\ElasticEmail\Facades\ElasticEmail::class,

Finally switch your default mail provider to elastic email in your .env file by setting MAIL_DRIVER=elastic_email

Outbound Email Tracking

To keep track of all emails sent by the driver you'll need to publish the migrations and the configuration files:

php artisan vendor:publish --provider="SeinOxygen\ElasticEmail\ApiServiceProvider" --tag="migrations"
php artisan migrate
php artisan vendor:publish --provider="SeinOxygen\ElasticEmail\ApiServiceProvider" --tag="config"

By default all outgoing emails will be stored with the Elastic Email message_id and transaction_id.

Check config/elasticemail.php for more options.

Linking Outgoing Emails To Your Models

In your mailable be sure to set the with array the following way.

public function build()
    // You can set ad many models you want to relate with the outgoing email
    $models = [
        [$yourmodel->id, get_class($yourmodel)],

    return $this
        ->subject("My Subject")
            'models' => $models

Sorry if it looks ugly. I haven't found a better way to do this...yet.

Capturing Webhook Events

You will need to set a webhook in Elastic Email service pointing to

There is an event being fired when data is sent to the webhook url.


namespace app\Listeners;

use SeinOxygen\ElasticEmail\Events\WebhookCallReceived;

class WebhookCallListerner
    public function handle(WebhookCallReceived $event)
        $request = $event->request;

Api Usage

For documentation visit

    //For contact

    //For emails


This package is based on ZanySoft


The MIT License (MIT). Please see License File for more information.