在 symfony 中发送电子邮件

发布于 2024-12-23 06:33:44 字数 731 浏览 6 评论 0原文

我在 symfony 1.4.8(以及 Doctrine 作为 ORM)中使用 swiftmailer (传输)来发送我的邮件。

我已经按照书上的说明配置了一切。

dev:
  mailer:
    class: sfMailer
    param:
      delivery_strategy: spool
      spool_class:       Swift_DoctrineSpool
      spool_arguments:   [ MailMessage, message, getSpooledMessages ]
      transport:
        class: Swift_SmtpTransport
        param:
          host: something
          port: 26
          encryption: ~
          username: something
          password: something

问题是当我使用实时策略时,发送邮件需要太多时间,用户应该等到它完成。然后动作就完成了,你可以看到结果。这对我来说不好,因为我想发送一封验证邮件以进行用户注册,如果速度很慢,用户将在注册过程中入睡。

而且我也不能使用假脱机策略。因为我必须通过任务手动发送它们(我对吗?),而我也不能这样做。因为注册后应该会自动发送。

那么针对这种情况有策略吗?这对于发送电子邮件来说已经足够快了(无需等到发送)

I'm using swiftmailer (transport) in symfony 1.4.8 (and Doctrine as ORM) to send my mails.

I've configured everything as the book says.

dev:
  mailer:
    class: sfMailer
    param:
      delivery_strategy: spool
      spool_class:       Swift_DoctrineSpool
      spool_arguments:   [ MailMessage, message, getSpooledMessages ]
      transport:
        class: Swift_SmtpTransport
        param:
          host: something
          port: 26
          encryption: ~
          username: something
          password: something

The problem is when I'm using realtime strategy , it takes too much time to send the mail and user should wait till it's done. Then the action is done and you can see the result . This is not good for me because I want to send a verification mail for user registration and if this is slow, user will fall sleep during the registration.

And I can't use spool strategy either. Because I have to send them manually with the task (am I right? ) and I can't do that too. Because it should be sent automatically after the registration.

So is there a strategy for this situation? That is fast enough for sending emails(without need to wait until it's sent)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蹲墙角沉默 2024-12-30 06:33:44

我使用实时策略发送电子邮件,有时循环发送数百封电子邮件。我发现电子邮件,尤其是在序列的早期发送时,相对较快。

我使用了以下技术:

  • Gmail 和 SSL 加密
  • 通过 API 的 SendGrid
  • 我自己的 API 使用电子邮件事务表,该表由发送电子邮件的任务扫描。

根据我的经验,一封确认电子邮件应该非常方便。如果不是,我会寻找其他(命令行)方法来调试该事务以查看瓶颈所在。我怀疑是 PHP、Symfony 还是 Swift。

I send emails using a realtime strategy, and sometimes hundreds in a loop. I find that emails, especially when sent early in the sequence, are relatively quick.

I've used the following techniques:

  • Gmail and SSL encryption
  • SendGrid through an API
  • My own API that used an email transaction table that gets swept by a task to send emails.

In my experience, a single confirmation email should be very expedient. If it isn't I would seek out other (command-line) ways to debug that transaction to see where you bottleneck is. I doubt that its PHP, Symfony or Swift.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文