diff --git a/lib/Alchemy/Phrasea/Notification/Deliverer.php b/lib/Alchemy/Phrasea/Notification/Deliverer.php index 6c7ef99b21..77b2661ab7 100644 --- a/lib/Alchemy/Phrasea/Notification/Deliverer.php +++ b/lib/Alchemy/Phrasea/Notification/Deliverer.php @@ -76,7 +76,11 @@ class Deliverer $message->setReadReceiptTo([$mail->getEmitter()->getEmail() => $mail->getEmitter()->getName()]); } + if(!$this->mailer->getTransport()->isStarted()) { + $this->mailer->getTransport()->start(); + } $ret = $this->mailer->send($message); + $this->mailer->getTransport()->stop(); $this->dispatcher->dispatch('phraseanet.notification.sent'); diff --git a/tests/Alchemy/Tests/Phrasea/Notification/DelivererTest.php b/tests/Alchemy/Tests/Phrasea/Notification/DelivererTest.php index 6ae92610ba..ae396fae4a 100644 --- a/tests/Alchemy/Tests/Phrasea/Notification/DelivererTest.php +++ b/tests/Alchemy/Tests/Phrasea/Notification/DelivererTest.php @@ -337,7 +337,20 @@ class DelivererTest extends \PhraseanetTestCase private function getMailerMock() { - return $this->getMockBuilder('\Swift_Mailer')->disableOriginalConstructor()->getMock(); + $mailer = $this->getMockBuilder('\Swift_Mailer') + ->disableOriginalConstructor() + ->getMock(); + + $transport = $this->getMock('Swift_Transport'); + $transport->expects($this->any()) + ->method('isStarted') + ->willReturn(true); + + $mailer->expects($this->any()) + ->method('getTransport') + ->willReturn($transport); + + return $mailer; } private function getEmitterMock()