public function loadMessage($mail)
    {
        $localFilePath = $this->getMailFolderPathById($mail->getId()) .
            DIRECTORY_SEPARATOR . self::MESSAGE_FILE_NAME;

        $messageJson = $this->restoreFile($localFilePath);

        if (empty($messageJson)) {
            $messageJson = '{}';
        }

        $messageData = json_decode($messageJson);

        /** @var \Shockwavemk\Mail\Base\Model\Mail\Message $message */
        $message = $this->_objectManager->create('Shockwavemk\Mail\Base\Model\Mail\Message');

        if (!empty($messageData->type)) {
            $message->setType($messageData->type);
        }

        if (!empty($messageData->txt)) {
            $message->setBodyText($messageData->txt);
        }

        if (!empty($messageData->html)) {
            $message->setBodyHtml($messageData->html);
        }

        if (!empty($messageData->from)) {
            $message->setFrom($messageData->from);
        }

        if (!empty($messageData->subject)) {
            $message->setSubject($messageData->subject);
        }

        if (!empty($messageData->recipients)) {
            foreach ($messageData->recipients as $recipient) {
                $message->addTo($recipient);
            }
        }

        return $message;
    }
public function loadMessage($mail)
    {
        $localFilePath = $this->getMailFolderPathById($mail->getId()) .
            DIRECTORY_SEPARATOR . self::MESSAGE_FILE_NAME;

        $messageJson = $this->restoreFile($localFilePath);

        if (empty($messageJson)) {
            $messageJson = '{}';
        }

        $messageData = json_decode($messageJson);

        /** @var \Shockwavemk\Mail\Base\Model\Mail\Message $message */
        $message = $this->_objectManager->create('Shockwavemk\Mail\Base\Model\Mail\Message');

        if (!empty($messageData->type)) {
            $message->setType($messageData->type);
        }

        if (!empty($messageData->txt)) {
            $message->setBodyText($messageData->txt);
        }

        if (!empty($messageData->html)) {
            $message->setBodyHtml($messageData->html);
        }

        if (!empty($messageData->from)) {
            $message->setFrom($messageData->from);
        }

        if (!empty($messageData->subject)) {
            $message->setSubject($messageData->subject);
        }

        if (!empty($messageData->recipients)) {
            foreach ($messageData->recipients as $recipient) {
                $message->addTo($recipient);
            }
        }

        return $message;
    }
public function loadMessage ( $ mail ) { $ localFilePath = $ this -> getMailFolderPathById ( $ mail -> getId ( ) ) . DIRECTORY_SEPARATOR . self :: MESSAGE_FILE_NAME ; $ messageJson = $ this -> restoreFile ( $ localFilePath ) ; if ( empty ( $ messageJson ) ) { $ messageJson = '{}' ; } $ messageData = json_decode ( $ messageJson ) ; /** @var \Shockwavemk\Mail\Base\Model\Mail\Message $message */ $ message = $ this -> _objectManager -> create ( 'Shockwavemk\Mail\Base\Model\Mail\Message' ) ; if ( ! empty ( $ messageData -> type ) ) { $ message -> setType ( $ messageData -> type ) ; } if ( ! empty ( $ messageData -> txt ) ) { $ message -> setBodyText ( $ messageData -> txt ) ; } if ( ! empty ( $ messageData -> html ) ) { $ message -> setBodyHtml ( $ messageData -> html ) ; } if ( ! empty ( $ messageData -> from ) ) { $ message -> setFrom ( $ messageData -> from ) ; } if ( ! empty ( $ messageData -> subject ) ) { $ message -> setSubject ( $ messageData -> subject ) ; } if ( ! empty ( $ messageData -> recipients ) ) { foreach ( $ messageData -> recipients as $ recipient ) { $ message -> addTo ( $ recipient ) ; } } return $ message ; }
Restore a message from filesystem

@param \Shockwavemk\Mail\Base\Model\Mail $mail
@return \Shockwavemk\Mail\Base\Model\Mail\Message $message
@throws \Exception
@throws \Zend_Mail_Exception
Restore a message from filesystem