Services/AzineNotifierService.php
public function sendNewsletterFor($recipientId, array $params, $wrapperTemplate)
    {
        $recipient = $this->recipientProvider->getRecipient($recipientId);

        // create new array for each recipient.
        $recipientParams = array_merge($params, $this->getRecipientSpecificNewsletterParams($recipient));

        // get the recipient-specific contentItems of the newsletter
        $recipientContentItems = $this->getRecipientSpecificNewsletterContentItems($recipient);

        // merge the recipient-specific and the general content items. recipient-specific first/at the top!
        $recipientParams[self::CONTENT_ITEMS] = $this->orderContentItems(array_merge($recipientContentItems, $params[self::CONTENT_ITEMS]));
        $recipientParams['_locale'] = $recipient->getPreferredLocale();

        if (0 == sizeof($recipientParams[self::CONTENT_ITEMS])) {
            return $recipient->getEmail();
        }

        $subject = $this->getRecipientSpecificNewsletterSubject($params[self::CONTENT_ITEMS], $recipientContentItems, $params, $recipient, $recipient->getPreferredLocale());

        // render and send the email with the right wrapper-template
        $sent = $this->mailer->sendSingleEmail($recipient->getEmail(), $recipient->getDisplayName(), $subject, $recipientParams, $wrapperTemplate.'.txt.twig', $recipient->getPreferredLocale());

        if ($sent) {
            // save that this recipient has recieved the newsletter
            return null;
        }

        return $recipient->getEmail();
    }
public function sendNewsletterFor($recipientId, array $params, $wrapperTemplate)
    {
        $recipient = $this->recipientProvider->getRecipient($recipientId);

        // create new array for each recipient.
        $recipientParams = array_merge($params, $this->getRecipientSpecificNewsletterParams($recipient));

        // get the recipient-specific contentItems of the newsletter
        $recipientContentItems = $this->getRecipientSpecificNewsletterContentItems($recipient);

        // merge the recipient-specific and the general content items. recipient-specific first/at the top!
        $recipientParams[self::CONTENT_ITEMS] = $this->orderContentItems(array_merge($recipientContentItems, $params[self::CONTENT_ITEMS]));
        $recipientParams['_locale'] = $recipient->getPreferredLocale();

        if (0 == sizeof($recipientParams[self::CONTENT_ITEMS])) {
            return $recipient->getEmail();
        }

        $subject = $this->getRecipientSpecificNewsletterSubject($params[self::CONTENT_ITEMS], $recipientContentItems, $params, $recipient, $recipient->getPreferredLocale());

        // render and send the email with the right wrapper-template
        $sent = $this->mailer->sendSingleEmail($recipient->getEmail(), $recipient->getDisplayName(), $subject, $recipientParams, $wrapperTemplate.'.txt.twig', $recipient->getPreferredLocale());

        if ($sent) {
            // save that this recipient has recieved the newsletter
            return null;
        }

        return $recipient->getEmail();
    }
public function sendNewsletterFor ( $ recipientId , array $ params , $ wrapperTemplate ) { $ recipient = $ this -> recipientProvider -> getRecipient ( $ recipientId ) ; // create new array for each recipient. $ recipientParams = array_merge ( $ params , $ this -> getRecipientSpecificNewsletterParams ( $ recipient ) ) ; // get the recipient-specific contentItems of the newsletter $ recipientContentItems = $ this -> getRecipientSpecificNewsletterContentItems ( $ recipient ) ; // merge the recipient-specific and the general content items. recipient-specific first/at the top! $ recipientParams [ self :: CONTENT_ITEMS ] = $ this -> orderContentItems ( array_merge ( $ recipientContentItems , $ params [ self :: CONTENT_ITEMS ] ) ) ; $ recipientParams [ '_locale' ] = $ recipient -> getPreferredLocale ( ) ; if ( 0 == sizeof ( $ recipientParams [ self :: CONTENT_ITEMS ] ) ) { return $ recipient -> getEmail ( ) ; } $ subject = $ this -> getRecipientSpecificNewsletterSubject ( $ params [ self :: CONTENT_ITEMS ] , $ recipientContentItems , $ params , $ recipient , $ recipient -> getPreferredLocale ( ) ) ; // render and send the email with the right wrapper-template $ sent = $ this -> mailer -> sendSingleEmail ( $ recipient -> getEmail ( ) , $ recipient -> getDisplayName ( ) , $ subject , $ recipientParams , $ wrapperTemplate . '.txt.twig' , $ recipient -> getPreferredLocale ( ) ) ; if ( $ sent ) { // save that this recipient has recieved the newsletter return null ; } return $ recipient -> getEmail ( ) ; }
Send the newsletter for one recipient.

@param int    $recipientId
@param array  $params          params and contentItems that are the same for all recipients
@param string $wrapperTemplate

@return string|null or the failed email addressess
Send the newsletter for one recipient .