Laravel package to send transactional SMSes and emails (mail driver) via Everlytic.
- PHP 8.0+
- Laravel 9.0+
composer require emotality/laravel-everlytic
php artisan vendor:publish --provider="Emotality\Everlytic\EverlyticServiceProvider"
- Add the following lines to your
.env
:
EVERLYTIC_URL="https://<everlytic_domain>.everlytic.net"
EVERLYTIC_USERNAME="<everlytic_username>"
EVERLYTIC_PASSWORD="<everlytic_password>"
- Add the
everlytic
block to themailers
array, inside yourconfig/mail.php
file:
'mailers' => [
...
'everlytic' => [
'transport' => 'everlytic',
],
],
- Update the
MAIL_MAILER
in your.env
:
MAIL_MAILER=everlytic
Just send emails like you normally would! 😄
\Everlytic::sms('+27820000001', "1st Line\n2nd Line\n3rd Line");
Response will be a bool
, true
if successful, false
if unsuccessful.
\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
]
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");
}
}
laravel-everlytic is released under the MIT license. See LICENSE for details.