rhysnhall/laravel-socketlabs-driver

Laravel mail driver for SocketLabs injection API.
15,950 2
Install
composer require rhysnhall/laravel-socketlabs-driver
Latest Version:1.0.0
PHP:^7.3|^8.0
License:MIT
Last Updated:Dec 30, 2021
Links: GitHub  ·  Packagist
Maintainer: rhysnhall

Laravel SocketLabs Driver

Latest Stable Version PHP Version Require

Adds a driver for the SocketLabs Injection API to Laravel's email services.

Requirements

  • PHP 7.3 or greater.
  • A SocketLabs account with a server ID and API key.

Install

Install the package with composer.

composer require rhysnhall/laravel-socketlabs-driver

Setup

Once you register and set up an account with SocketLabs, you'll be presented with a server ID and an API key. Add both of these to your ENV file.

SOCKET_LABS_API_KEY={your_key}
SOCKET_LABS_SERVER_ID={server_id}

Next, add the SocketLabs credentials to your config\services.php config file.

'socketlabs' => [
  'key' => env('SOCKET_LABS_API_KEY'),
  'id' => env('SOCKET_LABS_SERVER_ID')
]

Add the SocketLabs service provider to the config\app.php config file.

'providers' => [
  ...
  Rhysnhall\LaravelSocketLabsDriver\SocketLabsServiceProvider::class
]

The last step is to add the SocketLabs driver to the config\mail.php config file.

'mailers' => [
  ...
  'socketlabs' => [
    'transport' => 'socketlabs'
  ]
]

You may also want to set SocketLabs as your default mailer, depending on your setup. You'll need to update the MAIL_MAILER variable in your ENV file.

MAIL_MAILER=socketlabs

Config

You can directly add your config variables to the config\mail.php config file or create a new config file to hold these.

config\mail.php

'mailers' => [
  ...
  'socketlabs' => [
    'transport' => 'socketlabs',
    'retries' => 2,
    'timeout' => 120,
    'proxy_url' => 'https://example'
  ]
]

config\socketlabs.php

<?php

return [
  'retries' => 2,
  'timeout' => 120,
  'proxy_url' => 'https://example'
];

Usage

Use the driver as you would any other email driver.

App\Mail\Test

class Test extends Mailable {
  public function build()
  {
      return $this->from('sender@example.com')
        ->view('emails.html.test')
        ->text('emails.plain.test')
        ->attach(storage_path('test_image.png'));
  }
}

Mail::to('recipient@example.com')->send(new \App\Mail\Test);

Contributing

Help improve this package by contributing.

Before opening a pull request, please discuss the proposed changes via Github issue or email.

License

This project is licensed under the MIT License - see the LICENSE file for details

Related Packages

oriceon/toastr-5-laravel

Easy toastr notifications for Laravel 5

502,600 79
php-tmdb/laravel

Laravel Package for TMDB ( The Movie Database ) API. Provides easy access to the...

53,312 160
oriceon/oauth-5-laravel

OAuth Service Provider for Laravel 5

1,669,304 173
artdarek/oauth-4-laravel

OAuth Service Provider for Laravel 4

522,424 677
narutimateum/toastr-5.2-laravel

toastr.js for Laravel 5.2 easy notification like growl for example

37,567 13