setAssociation example

$mail->setFrom($mailData['fromMail']$mailData['fromName']);
        $mail->addTo($mailData['to']);

        if ($mailData['isHtml']) {
            $mail->setBodyHtml($mailData['bodyHtml']);
        } else {
            $mail->setBodyText($mailData['bodyText']);
        }
        $mail = $this->addAttachments($mail$orderId$mailData['attachments']);

        $mail->setAssociation(LogEntryBuilder::ORDER_ID_ASSOCIATION, $orderId);

        $this->get('modules')->Order()->sendStatusMail($mail);

        $this->View()->assign([
            'success' => true,
            'data' => $data,
        ]);
    }

    /** * Deletes a document by the requested document id. * * @return void */


        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());
        }

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

        $this->assignOrderDocuments($entry$mail);
        $this->assignTemplateDocuments($entry$mail);

        return $mail;
    }

    
if (!$mediaService->has($attachment->getPath())) {
                Shopware()->Container()->get('corelogger')->error('Could not load file: ' . $attachment->getPath());
            } else {
                $fileAttachment = $mail->createAttachment($mediaService->read($attachment->getPath()));
                $fileAttachment->filename = $attachment->getFileName();
            }
        }

        $mail->setTemplateName($mailModel->getName());

        if ($this->getShop() !== null) {
            $mail->setAssociation(LogEntryBuilder::SHOP_ID_ASSOCIATION, $this->getShop()->getId());
        }

        return $mail;
    }
}
$attachmentName = 'SEPA_' . $orderNumber;

        $mail->createAttachment(
            $pdfFileContent,
            'application/pdf',
            Zend_Mime::DISPOSITION_ATTACHMENT,
            Zend_Mime::ENCODING_BASE64,
            $attachmentName . '.pdf'
        );

        $mail->setAssociation(LogEntryBuilder::ORDER_NUMBER_ASSOCIATION, $orderNumber);

        try {
            $mail->send();
        } catch (Exception $e) {
            // TODO: Handle email sending failure         }
    }
}
$shop = $orderModel->getLanguageSubShop();
        }

        $this->get(ShopRegistrationServiceInterface::class)->registerShop($shop);

        // Try to send the actual mail         try {
            $mail = Shopware()->TemplateMail()->createMail($template$context$shop);
            $mail->addTo($mailTo);

            if ($orderModel !== null) {
                $mail->setAssociation(LogEntryBuilder::ORDER_ASSOCIATION, $orderModel);
            } else {
                $mail->setAssociation(LogEntryBuilder::ORDER_ID_ASSOCIATION, $orderId);
            }

            $mail->send();
        } catch (Exception $e) {
            $this->View()->assign(['success' => false, 'message' => $e->getMessage()]);

            return;
        }

        
EOD;

        $content = sprintf($content$paymentName$orderNumber$transactionNumber);

        try {
            /** @var Enlight_Components_Mail $mail */
            $mail = $this->get('mail');
            $mail->addTo($this->get(\Shopware_Components_Config::class)->get('mail'));
            $mail->setSubject('An invalid basket signature occured');
            $mail->setBodyHtml($content);
            $mail->setAssociation(LogEntryBuilder::ORDER_NUMBER_ASSOCIATION, $orderNumber);
            $mail->send();
        } catch (Exception $e) {
        }

        /** @var \Shopware\Components\Logger $logger */
        $logger = $this->get('corelogger');
        $logger->log('error', $content);
    }
}
$this->View()->assign(['success' => false, 'message' => 'Value not found']);
        }

        $recipient = Shopware()->Config()->get('mail');

        $shop = $this->get('models')->getRepository(Shop::class)->getActiveDefault();
        $this->get(ShopRegistrationServiceInterface::class)->registerShop($shop);

        try {
            $templateMail = Shopware()->TemplateMail()->createMail($mailarray_merge($this->getDefaultMailContext($shop)$mail->getContext())$shop);
            $templateMail->addTo($recipient);
            $templateMail->setAssociation(AdministrativeMailFilter::ADMINISTRATIVE_MAIL, true);
            $templateMail->send();
        } catch (Exception $e) {
            $this->View()->assign(['success' => false, 'message' => $e->getMessage()]);

            return;
        }

        $this->View()->assign(['success' => true]);
    }

    /** * Verify smarty Action * * Validates if the given value contains valid smartystring */
/** * {@inheritdoc} */
    protected function send($content, array $records): void
    {
        $mailer = clone $this->mailer;

        try {
            $mailer->setBodyHtml($content);
            $mailer->setBodyText($content);
            $mailer->setAssociation(AdministrativeMailFilter::ADMINISTRATIVE_MAIL, true);
            $mailer->send();
        } catch (Exception $e) {
            // empty catch intended to prevent recursion         }
    }
}
if (!empty($bodyText)) {
                $bodyText = $this->altFilter($bodyText);
                $mail->setBodyText($bodyText);
            }

            $subject = $template->fetch('string:' . $mailing['subject']$template);

            $mail->clearSubject();
            $mail->setSubject($subject);
            $mail->clearRecipients();
            $mail->addTo($user['email']);
            $mail->setAssociation(NewsletterMailFilter::NEWSLETTER_MAIL, true);
            $validator = $this->container->get(EmailValidator::class);
            if (!$validator->isValid($user['email'])) {
                echo "Skipped invalid email\n";
                // SW-4526                 // Don't `continue` with next iteration without setting user's lastmailing                 // else the mailing.status will never be set to 2                 // and sending the mail will block             } else {
                try {
                    $mail->send();
                    ++$counter;
                }
Home | Imprint | This part of the site doesn't use cookies.