/** * Sends the message. * * @return integer the number of recipients who were accepted for delivery * @author Karsten Dambekalns <*****@*****.**> */ public function send() { $this->initializeMailer(); $this->sent = TRUE; $this->getHeaders()->addTextHeader('X-Mailer', $this->mailerHeader); return $this->mailer->send($this, $this->failedRecipients); }
/** * @test */ public function sendCommandFlushsSpool() { $realTransportMock = $this->getMock('R3H6\\MailSpool\\Tests\\Unit\\Mail\\Fixtures\\TestTransport', array(), array(), '', false); $spoolMock = $this->getMock('Swift_FileSpool', array('setMessageLimit', 'setTimeLimit', 'recover', 'flushQueue'), array(), '', false); $spoolMock->expects($this->once())->method('setMessageLimit')->with($this->equalTo(3)); $spoolMock->expects($this->once())->method('setTimeLimit')->with($this->equalTo(5)); $spoolMock->expects($this->once())->method('recover')->with($this->equalTo(7)); $spoolMock->expects($this->once())->method('flushQueue')->with($this->equalTo($realTransportMock))->will($this->returnValue(9)); $transportMock = $this->getMock('R3H6\\MailSpool\\Mail\\SpoolTransport', array('getSpool', 'getRealTransport'), array(), '', false); $transportMock->expects($this->any())->method('getSpool')->will($this->returnValue($spoolMock)); $transportMock->expects($this->any())->method('getRealTransport')->will($this->returnValue($realTransportMock)); $this->mailer->expects($this->any())->method('getTransport')->will($this->returnValue($transportMock)); $this->subject->expects($this->at(2))->method('outputLine')->with($this->equalTo('<comment>9</comment> emails sent')); $this->subject->sendCommand(3, 5, 7); }
/** * @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); }
/** * @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(); }
/** * 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)); } }
/** * 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; }