You are currently reading the documentation for v5, while the latest version is v8.

Segmenting lists

On this page:


title: Using custom mailables

You can use your own mailable to be used when sending a campaign. Any mailable that extends Spatie\Mailcoach\Mails\CampaignMail is valid.

Here’s an example mailable;

use Spatie\Mailcoach\Mails\CampaignMail;

class MyCustomMailable extends CampaignMail
{
    public function build()
    {
        return $this->view('emails.your-custom-view');
    }
}

You can use it in a campaign like this:

Campaign::create()
    ->useMailable(MyCustomMailable::class)
    ->sendTo($emailList);
Segmenting lists