# Doing max of N tasks per given time

**URL:** <https://www.ruby-forum.com/t/doing-max-of-n-tasks-per-given-time/158725>\
**Category:** Rails\
**Created:** [January 27, 2009, 11:28am UTC](https://www.ruby-forum.com/t/doing-max-of-n-tasks-per-given-time/158725 "2009-01-27T11:28:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ramontayag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c6cbf5/32.png) [@ramontayag](https://www.ruby-forum.com/u/ramontayag)\
**Post date:** [January 27, 2009, 11:28am UTC](https://www.ruby-forum.com/t/doing-max-of-n-tasks-per-given-time/158725/1 "2009-01-27T11:28:28Z")

</div>

Hey everyone,

PROBLEM  
I need some help. I have a Rails app on a VPS that connects to an  
external SMTP server that can only send up to 250 emails per hour. If  
I try to send the 251st email, it will just ignore it.

SENDMAIL?  
I almost bashed my head trying to setup sendmail so I can send my own  
emails, but not all emails were being sent.

FANCY MOVES  
I basically want to send up to 250 emails immediately, and queue the  
251st email til after the next hour since the max limit of 250 will be  
reset. What can I use/install that does this for me? If I can avoid  
installing postfix and sendmail or some other MTA program, it’ll be  
way simpler for me.

Thanks,  
Ramon T.

---

<div class="post-metadata">

**Author:** ![ramontayag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c6cbf5/32.png) [@ramontayag](https://www.ruby-forum.com/u/ramontayag)\
**Post date:** [January 27, 2009, 7:01pm UTC](https://www.ruby-forum.com/t/doing-max-of-n-tasks-per-given-time/158725/2 "2009-01-27T19:01:37Z")

</div>

You should look into AR Mailer:

[http://seattlerb.rubyforge.org/ar\_mailer/](http://seattlerb.rubyforge.org/ar_mailer/)

The basic idea is that rather than actually sending emails, your app  
saves emails to the database. AR Mailer then has an external script  
which can be used to send these emails in batches.

Best of luck,

Greg

---

<div class="post-metadata">

**Author:** ![ramontayag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c6cbf5/32.png) [@ramontayag](https://www.ruby-forum.com/u/ramontayag)\
**Post date:** [January 28, 2009, 5:22am UTC](https://www.ruby-forum.com/t/doing-max-of-n-tasks-per-given-time/158725/3 "2009-01-28T05:22:19Z")

</div>

Thanks, Greg. I’ve taken a look.

I can have to Mailer models that have different uses: the first could  
be for immediate emailing (forgot password, account activation, etc),  
and the second, for less immediate email (site notifications,  
newsletters, etc) which will be a subclass of ARMailer.

Ramon T.
