简体   繁体   English

Rails ActionMailer在发送电子邮件之前增加了几毫秒的延迟

[英]Rails ActionMailer add a delay for few milliseconds before sending an email

Is there a way to achieve above at a single place, as we have lot of places to send email and can't change email sending calls to add a delay through out the application code base. 有没有一种方法可以在一个地方实现上述目标,因为我们有很多地方可以发送电子邮件,并且不能更改电子邮件发送呼叫以增加整个应用程序代码库的延迟。

We just want to make sure that not more than X emails are being sent in 1 second. 我们只想确保1秒内发送的电子邮件不超过X个。

We are using rails 2.3.5. 我们正在使用Rails 2.3.5。

Thanks 谢谢

EDIT 编辑

We are using Amazon SES for sending emails. 我们正在使用Amazon SES发送电子邮件。 Initially they allow 1 email per second. 最初,他们每秒允许1封电子邮件。 What happens if we send more than one emails per seconds. 如果我们每秒发送多个电子邮件,会发生什么情况。 Would SES queue them or throw some exception? SES会将它们排队还是抛出一些异常?

  1. Make your mail sending logic async by using a job queue, for example delayed_job or resque 使用作业队列(例如delay_jobresque)使您的邮件发送逻辑异步
  2. Have a job processor that takes jobs from the queue and processes them, as such you can control the sending interval from the processor logic 拥有一个作业处理器,该处理器从队列中取出作业并对其进行处理,因此您可以从处理器逻辑中控制发送间隔

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM