LaravelPackages.net
Acme Inc.
Toggle sidebar
emotality/laravel-everlytic

Laravel package to send transactional SMSes and emails (mail driver) via Everlytic.

485
3
2.3.6
About emotality/laravel-everlytic

emotality/laravel-everlytic is a Laravel package for laravel package to send transactional smses and emails (mail driver) via everlytic.. It currently has 3 GitHub stars and 485 downloads on Packagist (latest version 2.3.6). Install it with composer require emotality/laravel-everlytic. Discover more Laravel packages by emotality or browse all Laravel packages to compare alternatives.

Last updated

Everlytic for Laravel

License Latest Version Total Downloads

Laravel package to send transactional SMSes and emails (mail driver) via Everlytic.

Minimum Requirements

  • PHP 8.1
  • Laravel 10

Installation

  1. composer require emotality/laravel-everlytic
  2. php artisan vendor:publish --provider="Emotality\Everlytic\EverlyticServiceProvider"
  3. Add the following lines to your .env:
EVERLYTIC_URL="https://<everlytic_domain>.everlytic.net"
EVERLYTIC_USERNAME="<everlytic_username>"
EVERLYTIC_PASSWORD="<everlytic_password>"
  1. Add the everlytic block to the mailers array, inside your config/mail.php file:
'mailers' => [
    ...
    'everlytic' => [
        'transport' => 'everlytic',
    ],
],
  1. Update the MAIL_MAILER in your .env:
MAIL_MAILER=everlytic

Usage

Sending an email:

Just send emails like you normally would! :smile:


Sending an SMS to a single recipient:

\Everlytic::sms('+27820000001', "1st Line\n2nd Line\n3rd Line");

Response will be a bool, true if successful, false if unsuccessful.


Sending an SMS to multiple recipients:

\Everlytic::smsMany(['+27820000001', '+27820000002'], "1st Line\n2nd Line\n3rd Line");

Response will be an array where the keys are the recipients' numbers, the values will be booleans:

array:2 [â–¼
  "+27820000001" => true
  "+27820000002" => false
]

Sending an email and/or SMS via notification:

namespace App\Notifications;

use Emotality\Everlytic\EverlyticSms;
use Emotality\Everlytic\EverlyticSmsChannel;
use Illuminate\Notifications\Notification;

class ExampleNotification extends Notification
{
    // Notification channels
    public function via($notifiable)
    {
        return ['mail', EverlyticSmsChannel::class];
    }
    
    // Send email
    public function toMail($notifiable)
    {
        return new \App\Mail\ExampleMail($notifiable);
    }
    
    // Send SMS
    public function toSms($notifiable) // Can also use toEverlytic($notifiable)
    {
        // Send SMS to a single recipient
        return (new EverlyticSms())
            ->to($notifiable->mobile) // Assuming $user->mobile
            ->message("1st Line\n2nd Line\n3rd Line");
            
        // or send SMS to multiple recipients
        return (new EverlyticSms())
            ->toMany(['+27820000001', '+27820000002'])
            ->message("1st Line\n2nd Line\n3rd Line");
    }
}

License

laravel-everlytic is released under the MIT license. See LICENSE for details.

Comments