/** * Send a mail using this transport * * @return void * @throws \Magento\Framework\Exception\MailException */ public function sendMessage() { try { $attachments = $this->getMail()->getAttachments(); /** @noinspection IsEmptyFunctionUsageInspection */ if (!empty($attachments)) { foreach ($attachments as $attachment) { $this->_message->addAttachment($attachment->toMimePart()); } } $this->getMail()->setSent(false)->setSentAt($this->createSentAt())->setTransportId(uniqid($this->_message->getSubject(), true)); parent::send($this->_message); $this->getMail()->setSent(true); } catch (\Exception $e) { throw new \Magento\Framework\Exception\MailException(new \Magento\Framework\Phrase($e->getMessage()), $e); } }