/** * Flushs the memory queue. * * @return void */ protected function flushMemoryQueue() { if ($this->memorySpool !== null) { $mailer = $this->getMailer(); $transport = $mailer->getTransport(); if ($transport instanceof \R3H6\MailSpool\Mail\SpoolTransport) { $failedRecipients = array(); try { $sent = $this->memorySpool->flushQueue($transport->getRealTransport(), $failedRecipients); if (!$sent) { throw new \RuntimeException('No e-mail has been sent', 1476304931); } } catch (\Exception $exception) { \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog($exception->getMessage(), 'mail_spool', \TYPO3\CMS\Core\Utility\GeneralUtility::SYSLOG_SEVERITY_ERROR); } } } }
public function testEmbeddedImagesAreEmbedded() { $message = Swift_Message::newInstance()->setFrom('*****@*****.**')->setTo('*****@*****.**')->setSubject('test'); $cid = $message->embed(Swift_Image::fromPath(__DIR__ . '/../../_samples/files/swiftmailer.png')); $message->setBody('<img src="' . $cid . '" />', 'text/html'); $that = $this; $messageValidation = function (Swift_Mime_Message $message) use($that) { preg_match('/cid:(.*)"/', $message->toString(), $matches); $cid = $matches[1]; preg_match('/Content-ID: <(.*)>/', $message->toString(), $matches); $contentId = $matches[1]; $that->assertEquals($cid, $contentId, 'cid in body and mime part Content-ID differ'); return true; }; $failedRecipients = array(); $transport = m::mock('Swift_Transport'); $transport->shouldReceive('isStarted')->andReturn(true); $transport->shouldReceive('send')->with(m::on($messageValidation), $failedRecipients)->andReturn(1); $memorySpool = new Swift_MemorySpool(); $memorySpool->queueMessage($message); $memorySpool->flushQueue($transport, $failedRecipients); }
public function testIfEmailChangesAfterQueued() { $failedRecipients = 'value'; $message = new Swift_Message(); $message->setTo('*****@*****.**'); $that = $this; $messageValidation = function ($m) use($that) { // the getTo should return the same value as we put in $that->assertEquals('*****@*****.**', key($m->getTo()), 'The message has changed after it was put to the memory queue'); return true; }; $transport = m::mock('Swift_Transport'); $transport->shouldReceive('isStarted')->andReturn(true); $transport->shouldReceive('send')->with(m::on($messageValidation), $failedRecipients)->andReturn(1); $memorySpool = new Swift_MemorySpool(); $memorySpool->queueMessage($message); /* * The message is queued in memory. * Lets change the message */ $message->setTo('*****@*****.**'); $memorySpool->flushQueue($transport, $failedRecipients); }