How de we send out 5000 emails per hour using actionmailer in ruby on rails?

后端 未结 4 1126
悲哀的现实
悲哀的现实 2020-12-09 23:47

I have some questions about ActionMailer :

  1. How does Actionmailer connect to a smtp server ?

  2. Are the connections c

4条回答
  •  渐次进展
    2020-12-10 00:11

    Simple solution here for you... Sidekiq or Resque

    I'd highly recommend Sidekiq as it's not near as server intense for running multiple workers for this one - only be careful with concurrency issues (make sure you don't have 2 workers pick up the same job and send duplicate emails that is).

    Say you set 20 Sidekiq workers, each should be able to send an email every 2-4 seconds, you're looking at an easy 300-600 per minute.

    DO NOT try to do this without background workers like Sidekiq, Resque, or DelayedJob. You will freeze your entire app if you try sending in app with any large amount of emails. Even sending activation emails in app and what not will cause you unnecessary slow down issues.

    I'd have one Worker that handles the queueing periodically and another Worker class that handles the sending. We're using Resque (6 workers maybe?) for this on an older app (pre-sidekiq) to send around 500 emails every 5 minutes with no issues.

    You can aways use a third party like someone mentioned. Sendgrid is decent. But that wasn't the question, this is how you do it yourself simply and easily.

提交回复
热议问题