@@ -14,9 +14,89 @@ If you're just looking for a mailjet mail transport, check out [mailjet/laravel-
1414
1515 composer require yieldstudio/laravel-mailjet-notifier
1616
17+ ## Configure
18+
19+ Just define these environment variables:
20+
21+ ``` dotenv
22+ MAILJET_APIKEY=
23+ MAILJET_APISECRET=
24+ MAILJET_SMSTOKEN=
25+ MAIL_FROM_ADDRESS=
26+ MAIL_FROM_NAME=
27+ MAILJET_SMS_SENDER=
28+ ```
29+
30+ Make sure that MAIL_FROM_ADDRESS is an authenticated email on Mailjet, otherwise your emails will not be sent by the Mailjet API.
31+
32+ MAILJET_SMS_SENDER should be between 3 and 11 characters in length, only alphanumeric characters are allowed.
33+
34+ You can publish the configuration file with:
35+
36+ ``` shell
37+ php artisan vendor:publish --provider=" YieldStudio\LaravelMailjetNotifier\MailjetNotifierServiceProvider" --tag=" config"
38+ ```
39+
1740## Usage
1841
19- TODO
42+ ### Send email
43+
44+ ``` php
45+ <?php
46+
47+ namespace App\Notifications;
48+
49+ use Illuminate\Notifications\Notification;
50+ use YieldStudio\LaravelMailjetNotifier\MailjetEmailChannel;
51+
52+ class OrderConfirmation extends Notification
53+ {
54+ public function channels(): array
55+ {
56+ return [MailjetEmailChannel::class];
57+ }
58+
59+ public function toMailjetEmail($notifiable): MailjetEmailMessage
60+ {
61+ return (new MailjetEmailMessage())
62+ ->templateId(999999) // Replace with your template ID
63+ ->to($notifiable->firstname, $notifiable->email)
64+ ->variable('firstname', $notifiable->firstname)
65+ ->variable('order_ref', 'N°0000001');
66+ }
67+ }
68+ ```
69+
70+ ### Send sms
71+
72+ ``` php
73+ <?php
74+
75+ namespace App\Notifications;
76+
77+ use Illuminate\Notifications\Notification
78+ ;use YieldStudio\LaravelMailjetNotifier\MailjetSmsChannel;
79+ use YieldStudio\LaravelMailjetNotifier\MailjetSmsMessage;
80+
81+ class ResetPassword extends Notification
82+ {
83+ public function __construct(protected string $code)
84+ {
85+ }
86+
87+ public function via()
88+ {
89+ return [MailjetSmsChannel::class];
90+ }
91+
92+ public function toMailjetSms($notifiable): MailjetSmsMessage
93+ {
94+ return (new MailjetSmsMessage())
95+ ->to($notifiable->phone)
96+ ->text(__('This is your reset code :code', ['code' => $this->code]));
97+ }
98+ }
99+ ```
20100
21101## Unit tests
22102
0 commit comments