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

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