/** * Save file to spool path * * @param \Shockwavemk\Mail\Base\Model\Mail $mail * @return $this * @throws \Magento\Framework\Exception\MailException * @throws \Magento\Framework\Exception\FileSystemException * @throws \Exception */ public function saveMessage($mail) { // convert message to html $messageHtml = quoted_printable_decode($mail->getMessage()->getBodyHtml(true)); $this->createFolder($this->getMailFolderPathById($mail->getId())); // try to store message to filesystem $this->storeFile($messageHtml, $this->getMailFolderPathById($mail->getId()) . DIRECTORY_SEPARATOR . self::MESSAGE_HTML_FILE_NAME); // convert message to json $messageJson = json_encode($mail->getMessage()); // try to store message to filesystem $this->storeFile($messageJson, $this->getMailFolderPathById($mail->getId()) . DIRECTORY_SEPARATOR . self::MESSAGE_FILE_NAME); return $this; }