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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners