protected function getMailer()
    {
        $transport = null;
        if ($this->configurationManager->getSetting('mailer.type') === 'sendmail') {
            $transport = \Swift_SendmailTransport::newInstance($this->configurationManager->getSetting('mailer.sendmailCommand'));
        } else if ($this->configurationManager->getSetting('mailer.type') === 'smtp') {
            $host = $this->configurationManager->getSetting('mailer.smtpHost');
            $port = $this->configurationManager->getSetting('mailer.smtpPort');
            $username = $this->configurationManager->getSetting('mailer.smtpUsername');
            $password = $this->configurationManager->getSetting('mailer.smtpPassword');
            
            $transport = \Swift_SmtpTransport::newInstance($host, $port);
            $transport->setUsername($username);
            $transport->setPassword($password);
        }
        
        if ($transport === null) {
            throw new Exception('No mail transport defined. Please check your configuration.');
        }

        return \Swift_Mailer::newInstance($transport);
    }