PHP code example of loots-it / laravel-mail-template-channel
1. Go to this page and download the library: Download loots-it/laravel-mail-template-channel library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
loots-it / laravel-mail-template-channel example snippets
'providers' => [
...
LootsIt\LaravelMailTemplateChannel\Providers\TestMailTemplateChannelServiceProvider::class,
LootsIt\LaravelMailTemplateChannel\Providers\MailTemplateDriverServiceProvider::class, // This one is auto discovered
...
],
MAILJET_APIKEY=YOUR_APIKEY
MAILJET_APISECRET=YOUR_APISECRET
'mailjet' => [
'key' => env('MAILJET_APIKEY'),
'secret' => env('MAILJET_APISECRET'),
],
return [
'from' => [
'email' => '[email protected] ',
'name' => 'yourdomain.com',
],
];
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use LootsIt\LaravelMailTemplateChannel\ExternalMailTemplateChannel;
use LootsIt\LaravelMailTemplateChannel\MailTemplateMessage;
class VerifyEmailNotification extends Notification
{
use Queueable;
private int $templateID;
private string $verificationLink;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct($templateID, $verificationLink)
{
$this->templateID = $templateID;
$this->verificationLink = $verificationLink;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return [ExternalMailTemplateChannel::class];
}
public function toExternalMailTemplate($notifiable) {
$variables = [
"verification_link" => $this->verificationLink,
];
$message = new MailTemplateMessage($this->templateID, $variables);
$message->subject = "Verify email address";
return $message;
}
}
$user->notify(New VerifyEmailNotification($templateID, $verificationLink));
php artisan vendor:publish --provider="LootsIt\LaravelMailTemplateChannel\Providers\MailTemplateDriverServiceProvider"
php artisan mailTemplateDriver:test 1
php artisan make:notification VerifyEmailNotification