• Reading time ~ 1 min
  • 21.08.2022

The Mailator package is an email scheduler for Laravel. It provides a lightweight package around configuring email schedules and templates based on application events:

use Binarcode\LaravelMailator\Tests\Fixtures\InvoiceReminderMailable;
use Binarcode\LaravelMailator\Tests\Fixtures\SerializedConditionCondition;
 
Binarcode\LaravelMailator\Scheduler::init('Invoice reminder.')
    ->mailable(new InvoiceReminderMailable($invoice))
    ->recipients('[email protected]', '[email protected]')
    ->constraint(new SerializedConditionCondition($invoice))
    ->days(3)
    ->before($invoice->due_date)
    ->save();

The above example takes a Mailable instance, recipients, a set of sending constraints that must evaluate to true, and the ability to schedule the email send "three days before the due date."

Apart from the above constraint() method, you can implement the package's Constraintable interface:

use Binarcode\LaravelMailator\Constraints\Constraintable;
 
class InvoiceReminderMailable extends Mailable implements Constraintable
{
    public function constraints(): array
    {
        return [
            new DynamicContraint
        ];
    }
}

This package also includes an email templating feature, which you can learn more about in the package readme. You can learn more about this package on GitHub: BinarCode/laravel-mailator.

Comments

No comments yet
Yurij Finiv

Yurij Finiv

Full stack

ABOUT

Professional Fullstack Developer with extensive experience in website and desktop application development. Proficient in a wide range of tools and technologies, including Bootstrap, Tailwind, HTML5, CSS3, PUG, JavaScript, Alpine.js, jQuery, PHP, MODX, and Node.js. Skilled in website development using Symfony, MODX, and Laravel. Experience: Contributed to the development and translation of MODX3 i...

About author CrazyBoy49z
WORK EXPERIENCE
Contact
Ukraine, Lutsk
+380979856297