Giter Club home page Giter Club logo

laravel-everlytic's Introduction

Everlytic for Laravel

License Latest Version Total Downloads

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

Requirements

  • PHP 8.0+
  • Laravel 9.0+

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! ๐Ÿ˜„


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.

laravel-everlytic's People

Contributors

emotality avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  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.