getContentHtml example

array_walk_recursive($salesChannelDecodestatic function D&$value): void {
            if ($value instanceof \stdClass) {
                $value = json_decode((string) json_encode($value), true, 512, \JSON_THROW_ON_ERROR);
            }
        });

        $this->getBrowser()
            ->request(
                'POST',
                '/api/_action/mail-template/send',
                [
                    'contentHtml' => $mailTemplate->getContentHtml(),
                    'contentPlain' => $mailTemplate->getContentPlain(),
                    'mailTemplateData' => [
                        'order' => $orderDecode,
                        'salesChannel' => $salesChannelDecode,
                    ],
                    'documentIds' => $documentIds,
                    'recipients' => ['d.dinh@shopware.com' => 'Duy'],
                    'salesChannelId' => $salesChannel->getId(),
                    'senderName' => $salesChannel->getName(),
                    'subject' => 'New document for your order',
                    'testMode' => false,
                ],
if (!empty($fromMail) && !empty($fromName)) {
            $mail->setFrom($fromMail$fromName);
        } elseif (!empty($fromMail)) {
            $mail->setFrom($fromMail);
        }

        $bodyText = $stringCompiler->compileString($mailModel->getContent());
        $mail->setBodyText($bodyText);

        if ($mailModel->isHtml()) {
            $mail->setBodyHtml($stringCompiler->compileString($mailModel->getContentHtml()));
        }

        foreach ($mailModel->getAttachments() as $attachment) {
            if ($attachment->getShopId() !== null
                && ($this->getShop() === null || $attachment->getShopId() !== $this->getShop()->getId())) {
                continue;
            }

            $mediaService = Shopware()->Container()->get(MediaServiceInterface::class);
            if (!$mediaService->has($attachment->getPath())) {
                Shopware()->Container()->get('corelogger')->error('Could not load file: ' . $attachment->getPath());
            }
$mail->addTo($recipient->getMailAddress());
        });

        if ($entry->getSubject() !== null) {
            $mail->setSubject($entry->getSubject());
        }

        if ($entry->getContentText() !== null) {
            $mail->setBodyText($entry->getContentText());
        }

        if ($entry->getContentHtml() !== null) {
            $mail->setBodyHtml($entry->getContentHtml());
        }

        if ($entry->getType() !== null) {
            $mail->setTemplateName($entry->getType()->getName());
        }

        if ($entry->getOrder() !== null) {
            $mail->setAssociation(LogEntryBuilder::ORDER_ASSOCIATION, $entry->getOrder());
        }

        
try {
            $contacts = $this->loadContacts();

            foreach ($this->entries as $entry) {
                $this->connection->insert('s_mail_log', [
                    'type_id' => $entry->getType() ? $entry->getType()->getId() : null,
                    'order_id' => $entry->getOrder() ? $entry->getOrder()->getId() : null,
                    'shop_id' => $entry->getShop() ? $entry->getShop()->getId() : null,
                    'subject' => $entry->getSubject(),
                    'sender' => (string) $entry->getSender(),
                    'sent_at' => $entry->getSentAt()->format('Y-m-d H:i:s'),
                    'content_html' => $entry->getContentHtml(),
                    'content_text' => $entry->getContentText(),
                ]);
                $mailLogId = (int) $this->connection->lastInsertId();

                foreach ($entry->getDocuments() as $document) {
                    $this->connection->insert('s_mail_log_document', [
                        'log_id' => $mailLogId,
                        'document_id' => $document->getId(),
                    ]);
                }

                
Home | Imprint | This part of the site doesn't use cookies.