Is there an easy way to set a maximum rate for Actionmailer to send out emails? I’m using Amazon SES which drops messages sent at more than 5 per second and i want to avoid hitting that…
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There’s no easy solution to this. When you call a
delivermethod, ActionMailer sends the message synchronously: it immediately sends the message, and the caller waits for it to finish sending.So, since ActionMailer isn’t running in the background to process a queue of messages, it can’t really keep track of its rate or postpone a delivery.
But! It looks like Rails 4 will support asynchronous ActionMailer, based on the resque-mailer gem which is usable today (with some extra setup). From there, you might be able to look at limiting the rate at which Resque processes the enqueued jobs.