duanhongyi2964 2013-12-11 08:38 采纳率: 100%
浏览 95
已采纳

Symfony2 SwiftMailer - 如何在不等待服务器响应的情况下发送电子邮件

I am using swiftmailer to send one single email with about 300 BCC. The problem is that I am getting a 30sec timeout on the client side when doing this.

When checking on the server side, the mails were sent correctly, but sending all those emails take some time because the mail server deals with a lot of emails.

Any idea on how to tell the swiftmailer not to wait for the server response and render the view.

I checked the How to Spool Emails from the coockbook, but I don't thing that I need to do it this way.

Any idea how could I do that? Thank you in advance.

  • 写回答

1条回答 默认 最新

  • douza6300 2013-12-11 09:26
    关注

    From the Symfony Docs:

    # app/config/config.yml
    swiftmailer:
        # ...
        spool: { type: memory }
    

    When you are using the SwiftmailerBundle to send an email from a Symfony2 application, it will default to sending the email immediately. You may, however, want to avoid the performance hit of the communication between Swift Mailer and the email transport, which could cause the user to wait for the next page to load while the email is sending. This can be avoided by choosing to "spool" the emails instead of sending them directly. This means that Swift Mailer does not attempt to send the email but instead saves the message to somewhere such as a file. Another process can then read from the spool and take care of sending the emails in the spool. Currently only spooling to file or memory is supported by Swift Mailer.

    http://symfony.com/doc/current/cookbook/email/spool.html

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

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵