public function getMessageBody($type = 'text')
    {
        $mime_types = [
            'text'         => 'text/plain',
            'html'         => 'text/html',
            'htmlEmbedded' => 'text/html',
        ];

        if (in_array($type, array_keys($mime_types))) {
            $part_type = $type === 'htmlEmbedded' ? 'html' : $type;
            $inline_parts = $this->getInlineParts($part_type);
            $body = empty($inline_parts) ? '' : $inline_parts[0];
        } else {
            throw new Exception(
                'Invalid type specified for getMessageBody(). Expected: text, html or htmlEmbeded.'
            );
        }

        if ($type == 'htmlEmbedded') {
            $attachments = $this->getAttachments();
            foreach ($attachments as $attachment) {
                if ($attachment->getContentID() != '') {
                    $body = str_replace(
                        '"cid:'.$attachment->getContentID().'"',
                        '"'.$this->getEmbeddedData($attachment->getContentID()).'"',
                        $body
                    );
                }
            }
        }

        return $body;
    }
public function getMessageBody($type = 'text')
    {
        $mime_types = [
            'text'         => 'text/plain',
            'html'         => 'text/html',
            'htmlEmbedded' => 'text/html',
        ];

        if (in_array($type, array_keys($mime_types))) {
            $part_type = $type === 'htmlEmbedded' ? 'html' : $type;
            $inline_parts = $this->getInlineParts($part_type);
            $body = empty($inline_parts) ? '' : $inline_parts[0];
        } else {
            throw new Exception(
                'Invalid type specified for getMessageBody(). Expected: text, html or htmlEmbeded.'
            );
        }

        if ($type == 'htmlEmbedded') {
            $attachments = $this->getAttachments();
            foreach ($attachments as $attachment) {
                if ($attachment->getContentID() != '') {
                    $body = str_replace(
                        '"cid:'.$attachment->getContentID().'"',
                        '"'.$this->getEmbeddedData($attachment->getContentID()).'"',
                        $body
                    );
                }
            }
        }

        return $body;
    }
public function getMessageBody ( $ type = 'text' ) { $ mime_types = [ 'text' => 'text/plain' , 'html' => 'text/html' , 'htmlEmbedded' => 'text/html' , ] ; if ( in_array ( $ type , array_keys ( $ mime_types ) ) ) { $ part_type = $ type === 'htmlEmbedded' ? 'html' : $ type ; $ inline_parts = $ this -> getInlineParts ( $ part_type ) ; $ body = empty ( $ inline_parts ) ? '' : $ inline_parts [ 0 ] ; } else { throw new Exception ( 'Invalid type specified for getMessageBody(). Expected: text, html or htmlEmbeded.' ) ; } if ( $ type == 'htmlEmbedded' ) { $ attachments = $ this -> getAttachments ( ) ; foreach ( $ attachments as $ attachment ) { if ( $ attachment -> getContentID ( ) != '' ) { $ body = str_replace ( '"cid:' . $ attachment -> getContentID ( ) . '"' , '"' . $ this -> getEmbeddedData ( $ attachment -> getContentID ( ) ) . '"' , $ body ) ; } } } return $ body ; }
Returns the email message body in the specified format

@param string $type text, html or htmlEmbedded

@return string Body
@throws Exception
Returns the email message body in the specified format