yieldstudio/laravel-mailjet-notifier
最新稳定版本:0.0.10
Composer 安装命令:
composer require yieldstudio/laravel-mailjet-notifier
包简介
Easily send Mailjet transactional email and sms with Laravel notifier.
README 文档
README
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 yieldstudio/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 MAILJET_SANDBOX=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.
When the sandbox mode is enabled, Mailjet API is called but the mail is not send by Mailjet (requires Send API v3.1).
You can publish the configuration file with:
php artisan vendor:publish --provider="YieldStudio\LaravelMailjetNotifier\MailjetNotifierServiceProvider" --tag="config"
Usage
Send email
<?php namespace App\Notifications; use Illuminate\Notifications\Notification; use YieldStudio\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 YieldStudio\LaravelMailjetNotifier\MailjetSmsChannel; use YieldStudio\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])); } }
Unit tests
To run the tests, just run composer install and composer test.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you've found a bug regarding security please mail contact@yieldstudio.fr instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 5.15k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-06-18