Example #1
0
 /**
  * @test
  */
 public function givenPortSettingIsRespected()
 {
     $this->subject->injectMailSettings(array('transport' => 'smtp', 'transport_smtp_server' => 'localhost:12345'));
     $this->subject->__construct();
     $port = $this->subject->getTransport()->getPort();
     $this->assertEquals(12345, $port);
 }
Example #2
0
    /**
     * @test
     */
    public function providingCorrectClassnameDoesNotThrowException()
    {
        if (!class_exists('t3lib_mail_SwiftMailerFakeTransport')) {
            // Create fake custom transport class
            eval('class t3lib_mail_SwiftMailerFakeTransport extends \\TYPO3\\CMS\\Core\\Mail\\MboxTransport {
				public function __construct($settings) {}
			}');
        }
        $this->fixture->injectMailSettings(array('transport' => 't3lib_mail_SwiftMailerFakeTransport'));
        $this->fixture->__construct();
    }
Example #3
0
 /**
  * When constructing, add the redirector plugin
  *
  * @param null|\Swift_Transport $transport optionally pass a transport to the constructor.
  * @throws \TYPO3\CMS\Core\Exception
  */
 public function __construct(\Swift_Transport $transport = NULL)
 {
     parent::__construct($transport);
     // get the email address that should be redirected
     if (!empty($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['environment']['redirectEmails'])) {
         $emails = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['environment']['redirectEmails'];
         if (is_array($emails)) {
             $whitelist = array();
             foreach ($emails as $email) {
                 $whitlelist[] = '#^' . $email . '$#';
             }
         } else {
             $whitelist = array('#^' . $emails . '$#');
         }
         $this->registerPlugin(new \Swift_Plugins_RedirectPlugin($emails, $whitelist));
     }
 }
Example #4
0
 /**
  * When constructing, also initializes the \Swift_Transport like configured
  *
  * @param null|\Swift_Transport $transport optionally pass a transport to the constructor.
  * @throws \TYPO3\CMS\Core\Exception
  */
 public function __construct(\Swift_Transport $transport = null)
 {
     parent::__construct($this->transport);
     $backupSettings = $this->mailSettings;
     $backupTransport = $this->transport;
     // initialize addtional transports as configured in extension configuration re-using core initialization method
     $extConf = GeneralUtility::removeDotsFromTS(unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['mailcopy']));
     foreach ($extConf['transports'] as $config) {
         if (false === (bool) $config['enabled']) {
             continue;
         }
         $type = $config['type'];
         $transportConfig = $config[$type];
         $this->mailSettings = array('transport' => $type);
         foreach ($transportConfig as $key => $value) {
             $this->mailSettings['transport_' . $type . '_' . $key] = $value;
         }
         $this->initializeTransport();
         $this->extraTransports[] = $this->transport;
     }
     $this->transport = $backupTransport;
     $this->mailSettings = $backupSettings;
 }