mailing = $mailing; $this->withSwiftMessage(function ($message) use ($mailing) { $message->getHeaders()->addTextHeader('X-Mailing-ID', $mailing->id); }); } /** * Get the message envelope. */ public function envelope(): Envelope { return new Envelope( subject:$this->mailing->subject, ); } /** * Get the message content definition. */ public function content(): Content { return new Content( htmlString: $this->mailing->message, ); } /** * Get the attachments for the message. * * @return array */ public function attachments(): array { return $this->mailing->attachments()->get()->map(function (ProjectMailingAttachment $attachment) { $mime = 'application/pdf'; // default MIME type $extension = pathinfo($attachment->path, PATHINFO_EXTENSION); if ($extension === 'docx') { $mime = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; } return Attachment::fromStorage( path: $attachment->mailing->project->download_path."/".$attachment->path ) ->as($attachment->path) ->withMime($mime); })->toArray(); } }