addTo example



        if (\array_key_exists('password', $context)) {
            unset($context['password']);
        }

        if (\array_key_exists('passwordConfirmation', $context)) {
            unset($context['passwordConfirmation']);
        }

        $mail = Shopware()->TemplateMail()->createMail('sREGISTERCONFIRMATION', $context);
        $mail->addTo($email);

        $sendConfirmationEmail = $this->config->get('sSEND_CONFIRM_MAIL');
        if (!empty($sendConfirmationEmail)) {
            $mail->addBcc($this->config->get('sMAIL'));
        }

        $this->eventManager->notify(
            'Shopware_Modules_Admin_SaveRegisterSendConfirmation_BeforeSend',
            ['subject' => $this, 'mail' => $mail]
        );

        


            unset($position);

            $context = [
                'sOrder' => $order,
                'sUser' => $customers[$orderId],
                'sArticles' => $orderPositions[$orderId],
            ];

            $mail = Shopware()->TemplateMail()->createMail('sARTICLECOMMENT', $context);
            $mail->addTo($customers[$orderId]['email']);
            $mail->send();
            ++$count;
        }

        if ($count <= 0) {
            return 'No rating mails sent.';
        }

        return $count . ' rating mail(s) sent.';
    }

    
$this->assertTrue($stream->isClosed());
    }

    public function testWriteEncodedRecipientAndSenderAddresses()
    {
        $stream = new DummyStream();

        $transport = new SmtpTransport($stream);

        $message = new Email();
        $message->from('sender@exämple.org');
        $message->addTo('recipient@exämple.org');
        $message->addTo('recipient2@example.org');
        $message->text('.');

        $transport->send($message);

        $this->assertContains("MAIL FROM:<sender@xn--exmple-cua.org>\r\n", $stream->getCommands());
        $this->assertContains("RCPT TO:<recipient@xn--exmple-cua.org>\r\n", $stream->getCommands());
        $this->assertContains("RCPT TO:<recipient2@example.org>\r\n", $stream->getCommands());
    }

    public function testAssertResponseCodeNoCodes()
    {
'sConfig' => Shopware()->Config(),
        ];
        $compiler->setContext($defaultContext);

        // Send eMail to customer         $mail->IsHTML(false);
        $mail->From = $compiler->compileString($fromMail);
        $mail->FromName = $compiler->compileString($fromName);
        $mail->Subject = $compiler->compileString($subject);
        $mail->Body = $compiler->compileString($content);
        $mail->clearRecipients();
        $mail->addTo($toMail);

        if (!$mail->send()) {
            $this->View()->assign(['success' => false, 'message' => 'The mail could not be sent.']);

            return;
        }
        if ($status == 'accepted') {
            $this->get('db')->query(
                " UPDATE s_user SET customergroup = validation, validation = '' WHERE id = ? ",
                [

                    $connection->executeQuery($sql[$hashserialize(Shopware()->System()->_POST->toArray())]);

                    $context = [
                        'sConfirmLink' => $link,
                        'sArticleName' => $name,
                    ];

                    $mail = $this->get('templatemail')->createMail('sACCEPTNOTIFICATION', $context);
                    $mail->addTo($email);
                    $mail->send();

                    $sNotificationArticleWaitingForOptInApprovement = $session->get('sNotifcationArticleWaitingForOptInApprovement', []);
                    $sNotificationArticleWaitingForOptInApprovement[$notifyOrderNumber] = true;
                    $session->set('sNotifcationArticleWaitingForOptInApprovement', $sNotificationArticleWaitingForOptInApprovement);
                } else {
                    $action->View()->assign('NotifyAlreadyRegistered', true);
                }
            }
        }

        
if (!$orderModel instanceof Order) {
            $shop = $this->get('models')->getRepository(Shop::class)->getActiveDefault();
        } else {
            $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()]);

            
if ((\count($availableSerials) <= $this->config->get('esdMinSerials')) || \count($availableSerials) <= $quantity) {
            // Not enough serial numbers anymore, inform merchant             $context = [
                'sArticleName' => $basketRow['articlename'],
                'sMail' => $this->sUserData['additional']['user']['email'] ?? null,
            ];

            $mail = Shopware()->TemplateMail()->createMail('sNOSERIALS', $context);

            if ($this->config->get('sESDMAIL')) {
                $mail->addTo($this->config->get('sESDMAIL'));
            } else {
                $mail->addTo($this->config->get('sMAIL'));
            }

            $mail->send();
        }

        // Check if enough serials are available, if not, an email has been sent, and we can return         if (\count($availableSerials) < $quantity) {
            return $basketRow;
        }

        
$shop = $repository->getActiveById($shopId);
            $this->get(ShopRegistrationServiceInterface::class)->registerShop($shop);

            // language subshopID             $context = [
                'sUser' => $user,
                'sVoucher' => $voucher,
                'sData' => $job['data'],
            ];

            $mail = Shopware()->TemplateMail()->createMail('sBIRTHDAY', $context);
            $mail->addTo($user['email']);
            $mail->send();
        }

        return \count($users) . ' birthday email(s) with voucher was send.';
    }
}
$context,
            [
                'customer' => $customer,
            ]
        );

        if (((int) $customer->getAccountMode()) === 1) {
            $mail = $container->get(Shopware_Components_TemplateMail::class)->createMail('sOPTINREGISTERACCOUNTLESS', $context);
        } else {
            $mail = $container->get(Shopware_Components_TemplateMail::class)->createMail('sOPTINREGISTER', $context);
        }
        $mail->addTo($customer->getEmail());
        $mail->send();
    }

    private function doubleOptInSaveHash(Customer $customer, string $hash): int
    {
        /** @var Request|null $request */
        $request = Shopware()->Container()->get('front')->Request();
        $fromCheckout = $request && $request->getParam('sTarget') === 'checkout';

        $sql = "INSERT INTO `s_core_optin` (`type`, `datum`, `hash`, `data`) VALUES ('swRegister', ?, ?, ?)";

        
/** @var Shopware_Components_Config $config */
        $config = $this->get(\Shopware_Components_Config::class);

        $logLevel = \Monolog\Logger::toMonologLevel($config->get('logMailLevel'));
        $recipients = array_filter(explode("\n", $config->get('logMailAddress')));

        if (\count($recipients) < 1) {
            $recipients[] = $config->get('mail');
        }

        $mailer = new \Enlight_Components_Mail();
        $mailer->addTo($recipients);
        $mailer->setSubject('Error in shop "' . $config->get('shopName') . '".');
        $mailHandler = new EnlightMailHandler($mailer$logLevel);
        $mailHandler->pushProcessor(new ShopwareEnvironmentProcessor());
        $mailHandler->setFormatter(new HtmlFormatter());

        return new BufferHandler($mailHandler, 0, Logger::ERROR);
    }
}

            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();
                    
$helene = new Address('helene@symfony.com');
        $thomas = new Address('thomas@symfony.com', 'Thomas');
        $caramel = new Address('caramel@symfony.com');

        $this->assertSame($e$e->to('fabien@symfony.com', $helene$thomas));
        $v = $e->getTo();
        $this->assertCount(3, $v);
        $this->assertEquals(new Address('fabien@symfony.com')$v[0]);
        $this->assertSame($helene$v[1]);
        $this->assertSame($thomas$v[2]);

        $this->assertSame($e$e->addTo('lucas@symfony.com', $caramel));
        $v = $e->getTo();
        $this->assertCount(5, $v);
        $this->assertEquals(new Address('fabien@symfony.com')$v[0]);
        $this->assertSame($helene$v[1]);
        $this->assertSame($thomas$v[2]);
        $this->assertEquals(new Address('lucas@symfony.com')$v[3]);
        $this->assertSame($caramel$v[4]);

        $e = new Email();
        $e->addTo('lucas@symfony.com', $caramel);
        $this->assertCount(2, $e->getTo());

        
$content = $this->View()->getAssign('sSupport');

        $mailBody = $this->replaceVariables($content['email_template']);
        $mailSubject = $this->replaceVariables($content['email_subject']);

        $receivers = explode(',', $content['email']);
        $receivers = array_map('trim', $receivers);

        $mail->setFrom(Shopware()->Config()->get('Mail'));
        $mail->clearRecipients();
        $mail->addTo($receivers);
        $mail->setBodyText($mailBody);
        $mail->setSubject($mailSubject);

        $mail = Shopware()->Events()->filter('Shopware_Controllers_Frontend_Forms_commitForm_Mail', $mail['subject' => $this]);

        if (!$mail->send()) {
            throw new Enlight_Exception('Could not send mail');
        }
    }

    /** * @param int $formId * * @throws Enlight_Exception * @throws Exception * * @return array */
public function build(Log $entry): Enlight_Components_Mail
    {
        $mail = clone $this->mail;

        try {
            $mail->setFrom($entry->getSender());
        } catch (RuntimeException $exception) {
            $mail->setFrom(self::INVALID_SENDER_REPLACEMENT_ADDRESS);
        }

        $entry->getRecipients()->map(function D$recipient) use ($mail) {
            $mail->addTo($recipient->getMailAddress());
        });

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

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

        if ($entry->getContentHtml() !== null) {
            
if (!$this->Request()->getParam('value')) {
            $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]);
    }

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