douju9272 2012-11-10 12:24
浏览 79
已采纳

无法使用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?

  • 写回答

1条回答 默认 最新

  • dongyao1915 2012-11-10 16:36
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab中使用gurobi时报错
  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂