setFrom example

/** * Filters the name to associate with the "from" email address. * * @since 2.3.0 * * @param string $from_name Name associated with the "from" email address. */
        $from_name = apply_filters( 'wp_mail_from_name', $from_name );

        try {
            $phpmailer->setFrom( $from_email$from_name, false );
        } catch ( PHPMailer\PHPMailer\Exception $e ) {
            $mail_error_data                             = compact( 'to', 'subject', 'message', 'headers', 'attachments' );
            $mail_error_data['phpmailer_exception_code'] = $e->getCode();

            /** This filter is documented in wp-includes/pluggable.php */
            do_action( 'wp_mail_failed', new WP_Error( 'wp_mail_failed', $e->getMessage()$mail_error_data ) );

            return false;
        }

        // Set mail's subject and body.
$this->productHydrator = $productHydrator;
    }

    /** * @return PriceRule */
    public function hydratePriceRule(array $data)
    {
        $price = new PriceRule();

        $price->setId((int) $data['__price_id']);
        $price->setFrom((int) $data['__price_from']);
        $price->setPrice((float) $data['__price_price']);
        $price->setPseudoPrice((float) $data['__price_pseudoprice']);
        $price->setRegulationPrice((float) $data['__price_regulation_price']);

        if (strtolower($data['__price_to']) === 'beliebig') {
            $price->setTo(null);
        } else {
            $price->setTo((int) $data['__price_to']);
        }

        if (isset($data['__priceAttribute_id'])) {
            
$mail->setReplyTo($postEmail);
        }

        $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');
        }
    }

    
'Shopware_Controllers_Order_SendMail_Prepare',
            $mailData,
            [
                'subject' => $this,
                'orderId' => $orderId,
                'mail' => $mail,
            ]
        );

        $mail->setSubject($mailData['subject']);

        $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);

        
if (!\is_array($mailing)) {
            return;
        }

        $template = $this->initTemplate($mailing);

        $from = $template->fetch('string:' . $mailing['sendermail']$template);
        $fromName = $template->fetch('string:' . $mailing['sendername']$template);

        /** @var Enlight_Components_Mail $mail */
        $mail = clone Shopware()->Container()->get('mail');
        $mail->setFrom($from$fromName);

        $counter = 0;
        foreach ($emails as $email) {
            $user = $this->getMailingUserByEmail($email);
            $template->assign('sUser', $user, true);
            $hash = $this->createHash((int) $user['mailaddressID'](int) $mailing['id']);
            $template->assign('sCampaignHash', $hash, true);
            $template->assign('sRecommendations', $this->getMailingSuggest($mailing['id']$user['userID']), true);

            /** @var array $voucher */
            $voucher = $template->getTemplateVars('sVoucher');
            
return $this->iterate($result);
    }

    /** * @return EsSearch */
    protected function buildSearchObject(SearchCriteria $criteria)
    {
        $search = new EsSearch();

        if ($criteria->offset) {
            $search->setFrom($criteria->offset);
        }
        if ($criteria->limit) {
            $search->setSize($criteria->limit);
        }

        if ($criteria->term) {
            $search->addQuery($this->buildSearchQuery($criteria));
        }

        if (!empty($criteria->conditions)) {
            $this->addFilters($search$criteria);
        }
$this->helper->addFilters($definition$criteria$search$context);
        $this->helper->addPostFilters($definition$criteria$search$context);
        $this->helper->addQueries($definition$criteria$search$context);
        $this->helper->addSortings($definition$criteria$search$context);
        $this->helper->addTerm($criteria$search$context$definition);

        $search->setSize(self::MAX_LIMIT);
        $limit = $criteria->getLimit();
        if ($limit !== null) {
            $search->setSize($limit);
        }
        $search->setFrom((int) $criteria->getOffset());

        return $search;
    }

    /** * @return array<string, mixed> */
    private function convertSearch(Criteria $criteria, EntityDefinition $definition, Context $context, Search $search): array
    {
        if (!$criteria->getGroupFields()) {
            $array = $search->toArray();
            


    private function buildSearch(Criteria $criteria, ShopContextInterface $context): EsSearch
    {
        $search = new EsSearch();

        $this->addConditions($criteria$context$search);
        $this->addCriteriaParts($criteria$context$search$criteria->getSortings());
        $this->addCriteriaParts($criteria$context$search$criteria->getFacets());

        if ($criteria->getOffset() !== null) {
            $search->setFrom($criteria->getOffset());
        }
        if ($criteria->getLimit() !== null) {
            $search->setSize($criteria->getLimit());
        }

        $search->addSort(new FieldSort('id', 'asc'));

        return $search;
    }

    /** * @param CriteriaPartInterface[] $criteriaParts */
if (empty($ids)) {
            return;
        }

        $groupIds = $this->getGroupIds($ids);

        $search = new EsSearch();
        $search->addQuery(new IdsQuery($groupIds), BoolQuery::FILTER);
        $search->addQuery(new TermQuery('filterable', true), BoolQuery::FILTER);
        $search->addSort(new FieldSort('name', 'asc'));
        $search->setFrom(0);
        $search->setSize(self::AGGREGATION_SIZE);

        $index = $this->indexFactory->createShopIndex($context->getShop(), PropertyMapping::TYPE);

        $arguments = [
            'index' => $index->getName(),
            'body' => $search->toArray(),
            'rest_total_hits_as_int' => true,
            'track_total_hits' => true,
        ];

        
$percent = (100 - $discount->getPercent()) / 100;

            $price = $reference->getPrice() * $percent;

            $pseudo = $reference->getPseudoPrice();

            $rule->setPrice($price);

            $rule->setPseudoPrice($pseudo);

            $rule->setFrom($discount->getQuantity());

            $rule->setCustomerGroup($customerGroup);

            $rule->setTo(null);
            if ($previous) {
                $previous->setTo($rule->getFrom() - 1);
            }

            $previous = $rule;
            $prices[] = $rule;
        }

        
$this->mail = $mail;
    }

    /** * {@inheritdoc} */
    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());
        }

        
'mailname' => $templateName,
            'mail' => $mail,
            'engine' => Shopware()->Template(),
        ]);

        $mail->clearSubject();
        $mail->setSubject($return['subject']);

        $mail->setBodyText($return[CartKey::POSITIONS]);

        $mail->clearFrom();
        $mail->setFrom($return['frommail']$return['fromname']);

        $mail->addTo($return['email']);

        return $mail;
    }

    /** * Set payment status by order id * * @param int $orderId * @param int $paymentStatusId * @param bool $sendStatusMail * @param string|null $comment */
/** * Magic setter method * * @param string $name */
    public function __set($name$value)
    {
        switch ($name) {
            case 'From':
                $fromName = $this->getFromName();
                $this->clearFrom();
                $this->setFrom($value$fromName);
                break;
            case 'FromName':
                $from = $this->getFrom();
                $this->clearFrom();
                $this->setFrom($from$value);
                break;
            case 'Subject':
                $this->clearSubject();
                $this->setSubject($value);
                break;
            case 'Body':
                
        return $output . '?=';
    }

    /** * @param bool $autoClear * * @return bool */
    public function send($autoClear = true)
    {
        if (isset($this->headers['From']) && ! empty($this->fromEmail)) {
            $this->setFrom($this->fromEmail, $this->fromName);
        }

        if (isset($this->headers['From'])) {
            $this->setErrorMessage(lang('Email.noFrom'));

            return false;
        }

        if ($this->replyToFlag === false) {
            $this->setReplyTo($this->headers['From']);
        }

        

    public function setFromToDefaultFrom() {
        $from = self::getDefaultFrom();
        if($from === null) {
            throw new Zend_Mail_Exception(
                'No default From Address set to use');
        }

        $this->setFrom($from['email']$from['name']);

        return $this;
    }

    /** * Sets Default ReplyTo-address and -name of the message * * @param string $email * @param string Optional $name * @return void */
    
Home | Imprint | This part of the site doesn't use cookies.