Closed nkeena closed 4 years ago
Finally got it to work by updating my mailable and view to what's below.
From what I can tell, the content from the Mailable's view is extracted by Mailcoach and used instead of the $campaign->html
. It also would not work when using a variable named $html
or $campaignHtml
. That's why I chose $emailContent
.
The documentation on using a custom mailable is kinda vague, so hopefully this helps anyone with a similar issue.
<?php
namespace App\Mail;
use App\EmailAttachment;
use Spatie\Mailcoach\Mails\CampaignMail;
class ClassMessage extends CampaignMail
{
public $emailContent;
public function build()
{
$this->emailContent = $this->campaign->html;
$this->view('emails.classes.message');
foreach (EmailAttachment::query()->where('campaign_id', $this->campaign->id)->get() as $attachment) {
$this->attachFromStorage($attachment->source);
}
return $this;
}
}
// emails/classes/message.blade.php
{!! $emailContent !!}
I'm running version
v2.13.0
. When using a custom mailable it's passing an empty string into line 34 of thePrepareEmailHtmlAction.php
. Am I missing something that needs to be added to my mailable to inject the HTML?This is the error I keep getting in my
failed_jobs
table only when using a custom mailable:This is my mailable. It's only extending
CampaignMail
as per the mailcoach documentation.