Laravel Mailator provides a featherweight system for configuring email schedulers and email templates based on application events. You can install this package via composer: composer require binarcode/laravel-mailator

BeforeInvoiceExpiresConstraint constraint: class BeforeInvoiceExpiresConstraint implements SendScheduleConstraint { public function canSend(MailatorSchedule $mailatorSchedule, Collection $log): bool { // your conditions return true; }}

To create an email template: $template = Binarcode\LaravelMailator\Models\MailTemplate::create([ 'name' => 'Welcome Email.', 'from_email' => 'from@bar.com', 'from_name' => 'From Bar', 'subject' => 'Welcome to Mailator.', 'html' => '

This could be done in the build method as shown below: class WelcomeMailatorMailable extends Mailable { use Binarcode\LaravelMailator\Support\WithMailTemplate; private Model $user; public function __construct(Model $user) { $this->user = $user; } public function build() { return $this->template(MailTemplate::firstWhere('name', 'Welcome Email.')); } public function getReplacers(): array { return [ Binarcode\LaravelMailator\Replacers\ModelAttributesReplacer::makeWithModel($this->user), function($html) { // }]; }}
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners