PHP code example of tightr / laravel-mail-template
1. Go to this page and download the library: Download tightr/laravel-mail-template 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/ */
tightr / laravel-mail-template example snippets
php artisan vendor:publish --provider="Tightr\MailTemplate\MailTemplateServiceProvider"
use MailTemplate;
$mailTemplate = MailTemplate::setSubject('Welcome aboard')
->setFrom(config('mail.name'), config('mail.email'))
->setRecipient('Recipient Name', '[email protected] ')
->setLanguage('en')
->setTemplate('welcome-aboard')
->addAttachment(storage_path('pdf/invoice.pdf'), 'invoice-42.pdf')
->trackClicks(true)
->trackOpens(true)
->setVariables([
'first_name' => 'Recipient',
]);
$response = $mailTemplate->send();
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return [MailTemplateChannel::class];
}
public function toMailTemplate($notifiable)
{
return MailTemplate::setSubject('Welcome aboard')
->setFrom(config('mail.name'), config('mail.email'))
->setRecipient('Recipient Name', '[email protected] ')
->setLanguage('en')
->setTemplate('welcome-aboard')
->addAttachment(storage_path('pdf/invoice.pdf'), 'invoice-42.pdf')
->trackClicks(true)
->trackOpens(true)
->setVariables([
'first_name' => 'Recipient',
]);
}
bash
composer
bash
composer
bash
php artisan make:notification WelcomeNotification