laravel-mailjet-notifier maintained by nanaaikinson
Description
Easily send Mailjet transactional email and sms with Laravel notifier.
Author
Last update
2025/08/08 17:30
(dev-main)
License
Downloads
0
Tags
laravel-mailjet-notifier
Easily send Mailjet transactional email and sms with Laravel notifier.
If you're just looking for a mailjet mail transport, check out mailjet/laravel-mailjet
Major version zero (0.y.z) is for initial development. Anything MAY change at any time. The public API SHOULD NOT be considered stable.
Installation
composer require nanaaikinson/laravel-mailjet-notifier
Configure
Just define these environment variables:
MAILJET_APIKEY=
MAILJET_APISECRET=
MAILJET_SMSTOKEN=
MAIL_FROM_ADDRESS=
MAIL_FROM_NAME=
MAILJET_SMS_SENDER=
MAILJET_DRY=true|false
Make sure that MAIL_FROM_ADDRESS is an authenticated email on Mailjet, otherwise your emails will not be sent by the Mailjet API.
MAILJET_SMS_SENDER should be between 3 and 11 characters in length, only alphanumeric characters are allowed.
When the dry mode is enabled, Mailjet API isn't called.
You can publish the configuration file with:
php artisan vendor:publish --provider="NanaAikinson\LaravelMailjetNotifier\MailjetNotifierServiceProvider" --tag="config"
Usage
Send email
<?php
namespace App\Notifications;
use Illuminate\Notifications\Notification;
use NanaAikinson\LaravelMailjetNotifier\MailjetEmailChannel;
class OrderConfirmation extends Notification
{
public function via(): array
{
return [MailjetEmailChannel::class];
}
public function toMailjetEmail($notifiable): MailjetEmailMessage
{
return (new MailjetEmailMessage())
->templateId(999999) // Replace with your template ID
->to($notifiable->firstname, $notifiable->email)
->variable('firstname', $notifiable->firstname)
->variable('order_ref', 'N°0000001');
}
}
Send sms
<?php
namespace App\Notifications;
use Illuminate\Notifications\Notification;
use NanaAikinson\LaravelMailjetNotifier\MailjetSmsChannel;
use NanaAikinson\LaravelMailjetNotifier\MailjetSmsMessage;
class ResetPassword extends Notification
{
public function __construct(protected string $code)
{
}
public function via()
{
return [MailjetSmsChannel::class];
}
public function toMailjetSms($notifiable): MailjetSmsMessage
{
return (new MailjetSmsMessage())
->to($notifiable->phone)
->text(__('This is your reset code :code', ['code' => $this->code]));
}
}