Doing max of N tasks per given time


#1

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.


#2

You should look into 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


#3

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.