configureEmailTemplate(); $copyTo = $this->identityContainer->getEmailCopyTo(); $this->transportBuilder->addTo( $this->identityContainer->getCustomerEmail(), $this->identityContainer->getCustomerName() ); if (!empty($copyTo)) { $this->transportBuilder->addTo($copyTo); $this->transportBuilder->setMessageData('to', $copyTo); } if (isset($this->filePath)) { $attachmentMime = [ 'type' => 'application/vnd.ms-excel', 'content' => $this->filePath, 'disposition' => \Laminas\Mime\Mime::DISPOSITION_ATTACHMENT, 'encoding' => \Laminas\Mime\Mime::ENCODING_BASE64, 'fileName' => 'order.xlsx' ]; $this->transportBuilder->setAttachmentMimePart($attachmentMime); } $transport = $this->transportBuilder->getTransport(); $transport->sendMessage(); } public function setAttachmentFile(string $filePath): static { $this->filePath = $filePath; return $this; } }