无法使用RabbitMQ和Symfony2发送Swift_Message

I'm using the RabbitMQBundle to integrate RabbitMQ into my symfony2 project. Everything works fine (I can produce and consume messages). However, whenever I try to send an email using a Swift_Message from a consumer, I never receive the email. Using mail('foo@bar.com', 'subject', 'message'); from the consumer does work though.

Here's the code I use to send the Swift_Message:

 $message = \Swift_Message::newInstance()
    ->setSubject($subject)
    ->setFrom('noreply@bar.com')
    ->setTo('foo@bar.com')
    ->setBody('Foo Bar');

  $this->container->get('mailer')->send($message);

This code works from within a "normal" controller or service. However, it doesn't work when triggered in a consumer by RabbitMQ.

Any got a clue?

You should disable swiftmailer's spool feature: remove the spool of the swiftmailer bundle configuration.

Get from

swiftmailer:
    # ...
    spool: { type: memory }

to

swiftmailer:
    # ...

You can read more about this feature here.