Zend_Mime_Part example


    public static function createFromMessage($message$boundary$EOL = Zend_Mime::LINEEND)
    {
        $parts = Zend_Mime_Decode::splitMessageStruct($message$boundary$EOL);

        $res = new self();
        foreach ($parts as $part) {
            // now we build a new MimePart for the current Message Part:             $newPart = new Zend_Mime_Part($part['body']);
            foreach ($part['header'] as $key => $value) {
                /** * @todo check for characterset and filename */
                switch(strtolower($key)) {
                    case 'content-type':
                        $newPart->type = $value;
                        break;
                    case 'content-transfer-encoding':
                        $newPart->encoding = $value;
                        break;
                    

    public function setBodyText($txt$charset = null, $encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE)
    {
        if ($charset === null) {
            $charset = $this->_charset;
        }

        $mp = new Zend_Mime_Part($txt);
        $mp->encoding = $encoding;
        $mp->type = Zend_Mime::TYPE_TEXT;
        $mp->disposition = Zend_Mime::DISPOSITION_INLINE;
        $mp->charset = $charset;

        $this->_bodyText = $mp;

        return $this;
    }

    /** * Return text body Zend_Mime_Part or string * * @param bool textOnly Whether to return just the body text content or the MIME part; defaults to false, the MIME part * @return false|Zend_Mime_Part|string */


        return $mail;
    }

    /** * Creates an attachment by a file path. */
    private function createAttachment(string $filePath, string $fileName): Zend_Mime_Part
    {
        $content = $this->container->get('shopware.filesystem.private')->read($filePath);
        $zendAttachment = new Zend_Mime_Part($content);
        $zendAttachment->type = 'application/pdf';
        $zendAttachment->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
        $zendAttachment->encoding = Zend_Mime::ENCODING_BASE64;
        $zendAttachment->filename = $fileName;

        return $zendAttachment;
    }

    private function getFileName(int $orderId, int $typeId): string
    {
        $localeId = $this->getOrderLocaleId($orderId);

        
 $text->getHeaders($this->EOL)
                  . $this->EOL
                  . $text->getContent($this->EOL)
                  . $this->EOL
                  . $boundaryLine
                  . $html->getHeaders($this->EOL)
                  . $this->EOL
                  . $html->getContent($this->EOL)
                  . $this->EOL
                  . $boundaryEnd;

            $mp           = new Zend_Mime_Part($body);
            $mp->type     = Zend_Mime::MULTIPART_ALTERNATIVE;
            $mp->boundary = $mime->boundary();

            $this->_isMultipart = true;

            // Ensure first part contains text alternatives             array_unshift($this->_parts, $mp);

            // Get headers             $this->_headers = $this->_mail->getHeaders();
            return;
        }
Home | Imprint | This part of the site doesn't use cookies.