src/NotifierEmailSwiftMailerService.php
private function _bootstrapMailMessage($messageId){
       //validate that the message exists
        if(!isset($this->messages[($messageId)])){
            throw new NotifierEmailException('Illegal attempt to bootstrap a message that doesnt exist');
        }
        
        $swiftMessage = new \Swift_Message();
        
        $swiftMessage->setFrom($this->configuration['EMAIL_FROM']);
        
        $arrMsgTo = array();
        
        //add receipients on main address
        foreach($this->messages[($messageId)]['TO'] as $emailUser) {
            if (isset($emailUser['name'])) {
                $arrMsgTo[($emailUser['email'])] = $emailUser['name'];
            } else {
                $arrMsgTo[] = $emailUser['email'];
            }
        }
        
        //embed the recipients to the Swift Message
        $swiftMessage->setTo($arrMsgTo);
        $arrMsgCC = array();
        
        if (array_key_exists('CC', $this->messages[($messageId)])) {
            //add recepients on CC
            foreach($this->messages[($messageId)]["CC"] as $emailUser){
                if (isset($emailUser['name'])) {
                    $arrMsgCC[($emailUser['email'])] = $emailUser['name'];
                } else {
                    $arrMsgCC[] = $emailUser['email'];
                }            
            }

            if (count($arrMsgCC)) {
                $swiftMessage->setCc($arrMsgCC);
            }            
        }
        
        //add recepients on bCC
        if (array_key_exists('BCC', $this->messages[($messageId)])) {
            //add recepients on BCC
            foreach($this->messages[($messageId)]["BCC"] as $emailUser){
                if (isset($emailUser['name'])) {
                    $arrMsgBCC[($emailUser['email'])] = $emailUser['name'];
                } else {
                    $arrMsgBCC[] = $emailUser['email'];
                }            
            }

            if (count($arrMsgBCC)) {
                $swiftMessage->setBcc($arrMsgBCC);
            }            
        }       

        //set ReturnPath
        $returnPath = $this->configuration['RETURN_PATH'];
        $swiftMessage->setReturnPath($returnPath);
        
        //Handle Attachments
        foreach($this->messages[($messageId)]['ATTACHMENTS'] as $attachmentFilename => $attachmentFilepath) {           
            if (!(is_int($attachmentFilename))) {
                $swiftMessage->attach(\Swift_Attachment::fromPath($attachmentFilepath)->setFilename($attachmentFilename));
            } else {
                $swiftMessage->attach(\Swift_Attachment::fromPath($attachmentFilepath));
            }

        }
        
        //add the subject
        $swiftMessage->setSubject($this->messages[($messageId)]["SUBJECT"]);
        
        //add the email altbody
        $swiftMessage->addPart($this->messages[($messageId)]["ALT_BODY"]);

        //set the message body (as HTML)
        $swiftMessage->setBody($this->messages[($messageId)]["MSG_HTML"], 'text/html');
                
        //Check for Anti-Flood Setting
        if (array_key_exists('USE_ANTIFLOOD', $this->configuration)) {
            $antiFloodConfig = $this->configuration['USE_ANTIFLOOD'];            
        } else {
            $antiFloodConfig = false;
        }
        
        //Set AntiFlood Settings
        if ($antiFloodConfig) {
            $antiFloodFrequencyMails   = $this->configuration['ANTIFLOOD_FREQUENCY_MAILS'];
            $antiFloodFrequencySeconds = $this->configuration['ANTIFLOOD_FREQUENCY_SECONDS'];
            $this->mailHandler->registerPlugin(
                new \Swift_Plugins_AntiFloodPlugin($antiFloodFrequencyMails, $antiFloodFrequencySeconds)
            );
        }
       
        //Check for Throttler Setting
        if (array_key_exists('USE_THROTTLER', $this->configuration)) {
            $throttlerConfig = $this->configuration['USE_THROTTLER'];            
        } else {
            $throttlerConfig = false;
        }
        
        //Set AntiFlood Settings
        if ($throttlerConfig) {
            $throttlerMailsPerMinute = $this->configuration['THROTTLER_MAILS_PER_MINUTE'];
            $throttlerBytesPerMinute = $this->configuration['THROTTLER_BYTES_PER_MINUTE'];
            $this->mailHandler->registerPlugin(
                new \Swift_Plugins_ThrottlerPlugin(
                    $throttlerMailsPerMinute,
                    \Swift_Plugins_ThrottlerPlugin::MESSAGES_PER_MINUTE
                )
            );
            $this->mailHandler->registerPlugin(
                new \Swift_Plugins_ThrottlerPlugin(
                    $throttlerBytesPerMinute,
                    \Swift_Plugins_ThrottlerPlugin::BYTES_PER_MINUTE
                )
            );            
        }
        
        $this->messages[($messageId)]['messageObj'] = $swiftMessage;
        
        //set the bootstrapped property to true
        $this->messages[($messageId)]["IS_BOOSTRAPPED"] = true;
    }
private function _bootstrapMailMessage($messageId){
       //validate that the message exists
        if(!isset($this->messages[($messageId)])){
            throw new NotifierEmailException('Illegal attempt to bootstrap a message that doesnt exist');
        }
        
        $swiftMessage = new \Swift_Message();
        
        $swiftMessage->setFrom($this->configuration['EMAIL_FROM']);
        
        $arrMsgTo = array();
        
        //add receipients on main address
        foreach($this->messages[($messageId)]['TO'] as $emailUser) {
            if (isset($emailUser['name'])) {
                $arrMsgTo[($emailUser['email'])] = $emailUser['name'];
            } else {
                $arrMsgTo[] = $emailUser['email'];
            }
        }
        
        //embed the recipients to the Swift Message
        $swiftMessage->setTo($arrMsgTo);
        $arrMsgCC = array();
        
        if (array_key_exists('CC', $this->messages[($messageId)])) {
            //add recepients on CC
            foreach($this->messages[($messageId)]["CC"] as $emailUser){
                if (isset($emailUser['name'])) {
                    $arrMsgCC[($emailUser['email'])] = $emailUser['name'];
                } else {
                    $arrMsgCC[] = $emailUser['email'];
                }            
            }

            if (count($arrMsgCC)) {
                $swiftMessage->setCc($arrMsgCC);
            }            
        }
        
        //add recepients on bCC
        if (array_key_exists('BCC', $this->messages[($messageId)])) {
            //add recepients on BCC
            foreach($this->messages[($messageId)]["BCC"] as $emailUser){
                if (isset($emailUser['name'])) {
                    $arrMsgBCC[($emailUser['email'])] = $emailUser['name'];
                } else {
                    $arrMsgBCC[] = $emailUser['email'];
                }            
            }

            if (count($arrMsgBCC)) {
                $swiftMessage->setBcc($arrMsgBCC);
            }            
        }       

        //set ReturnPath
        $returnPath = $this->configuration['RETURN_PATH'];
        $swiftMessage->setReturnPath($returnPath);
        
        //Handle Attachments
        foreach($this->messages[($messageId)]['ATTACHMENTS'] as $attachmentFilename => $attachmentFilepath) {           
            if (!(is_int($attachmentFilename))) {
                $swiftMessage->attach(\Swift_Attachment::fromPath($attachmentFilepath)->setFilename($attachmentFilename));
            } else {
                $swiftMessage->attach(\Swift_Attachment::fromPath($attachmentFilepath));
            }

        }
        
        //add the subject
        $swiftMessage->setSubject($this->messages[($messageId)]["SUBJECT"]);
        
        //add the email altbody
        $swiftMessage->addPart($this->messages[($messageId)]["ALT_BODY"]);

        //set the message body (as HTML)
        $swiftMessage->setBody($this->messages[($messageId)]["MSG_HTML"], 'text/html');
                
        //Check for Anti-Flood Setting
        if (array_key_exists('USE_ANTIFLOOD', $this->configuration)) {
            $antiFloodConfig = $this->configuration['USE_ANTIFLOOD'];            
        } else {
            $antiFloodConfig = false;
        }
        
        //Set AntiFlood Settings
        if ($antiFloodConfig) {
            $antiFloodFrequencyMails   = $this->configuration['ANTIFLOOD_FREQUENCY_MAILS'];
            $antiFloodFrequencySeconds = $this->configuration['ANTIFLOOD_FREQUENCY_SECONDS'];
            $this->mailHandler->registerPlugin(
                new \Swift_Plugins_AntiFloodPlugin($antiFloodFrequencyMails, $antiFloodFrequencySeconds)
            );
        }
       
        //Check for Throttler Setting
        if (array_key_exists('USE_THROTTLER', $this->configuration)) {
            $throttlerConfig = $this->configuration['USE_THROTTLER'];            
        } else {
            $throttlerConfig = false;
        }
        
        //Set AntiFlood Settings
        if ($throttlerConfig) {
            $throttlerMailsPerMinute = $this->configuration['THROTTLER_MAILS_PER_MINUTE'];
            $throttlerBytesPerMinute = $this->configuration['THROTTLER_BYTES_PER_MINUTE'];
            $this->mailHandler->registerPlugin(
                new \Swift_Plugins_ThrottlerPlugin(
                    $throttlerMailsPerMinute,
                    \Swift_Plugins_ThrottlerPlugin::MESSAGES_PER_MINUTE
                )
            );
            $this->mailHandler->registerPlugin(
                new \Swift_Plugins_ThrottlerPlugin(
                    $throttlerBytesPerMinute,
                    \Swift_Plugins_ThrottlerPlugin::BYTES_PER_MINUTE
                )
            );            
        }
        
        $this->messages[($messageId)]['messageObj'] = $swiftMessage;
        
        //set the bootstrapped property to true
        $this->messages[($messageId)]["IS_BOOSTRAPPED"] = true;
    }
function _bootstrapMailMessage() - Bootstrap a message for sending, clearing previous settings

@param   $messageId  - The message Id

@return void