Category: Laravel

I recently upgraded my app to Laravel 5.8 and one of the reasons I did it so soon this time was the mail driver support for Postmark.
In case you don't know Postmark, it's a great service that helps a lot with transactional emailing.
Postmark has a way of adding a Tag to a message and/or special meta content so you can do interesting stuff with it's API.
But how can we add those to the Mailable flow of Laravel?
I created a trait that looks like thisAnd then in any Mailable class I only set the "Tag" or "Meta"$mailable = new myMailable(); $mailable->setTag( 'Tag' ); $mailable->setMeta([ 'id' => 123 ]); Mail::to( 'mail@mail.com' )->send($mailable);and of course chain that to the mailable flow by using the Trait:class myMailable extends Mailable { use Postmarkable ; public function build () { return $this ->addPostmarkHeaders()->subject( 'My subject' )->markdown( 'markdownfile' ); } }And that's it :-)
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