Mailcoach can store transactional mails, record any opens and clicks, and even resend them.
Getting started
To work with transactional mails in Mailcoach, you should use
Spatie\Mailcoach\Domain\TransactionalMail\Mails\Concerns\StoresMail
trait on your Mailable class.
Storing mails
In the
build
function of your mailable, you should call the store
method provided by the trait.
class YourMailable extends Mailable
{
public function build()
{
$this
->store()
->view('mails.your-mailable')
}
}
Whenever this mailable is sent, Mailcoach will store and display it in the UI.
Tracking opens and clicks
When enabled with your email provider, transactional mails will track opens & clicks as well.
Tracking opens and/or clicks requires Mailcoach to store the mail, so you have to call store
separately.
class YourMailable extends Mailable
{
public function build()
{
$this
->store()
->view('mails.your-mailable')
}
}
Resending stored mails
You can resend stored transactional mails via the UI or by calling resend
on the Spatie\Mailcoach\Domain\TransactionalMail\Models\TransactionalMail
model
TransactionalMail::find($id)->resend();