public function deliver(MailInterface $mail, $readReceipt = false, array $attachments = null)
    {
        if (!$mail->getReceiver()) {
            throw new LogicException('You must provide a receiver for a mail notification');
        }

        $message = \Swift_Message::newInstance($this->prefix . $mail->getSubject(), $mail->renderHTML(), 'text/html', 'utf-8');
        $message->addPart($mail->getMessage(), 'text/plain', 'utf-8');

        $message->setFrom($this->emitter->getEmail(), $this->emitter->getName());
        $message->setTo($mail->getReceiver()->getEmail(), $mail->getReceiver()->getName());

        if ($mail->getEmitter()) {
            $message->setReplyTo($mail->getEmitter()->getEmail(), $mail->getEmitter()->getName());
        }

        if(is_array($attachments)) {
            foreach($attachments as $attachment) {
                $message->attach($attachment->As_Swift_Attachment());
            }
        }

        if ($readReceipt) {
            if (!$mail->getEmitter()) {
                throw new LogicException('You must provide an emitter for a ReadReceipt');
            }
            $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');

        return $ret;
    }