# Sending thousands of email with ar\_mailer

**URL:** <https://www.ruby-forum.com/t/sending-thousands-of-email-with-ar-mailer/151512>\
**Category:** Rails\
**Created:** [October 22, 2008, 10:12am UTC](https://www.ruby-forum.com/t/sending-thousands-of-email-with-ar-mailer/151512 "2008-10-22T10:12:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![g0nzo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3bc359/32.png) [@g0nzo](https://www.ruby-forum.com/u/g0nzo)\
**Post date:** [October 22, 2008, 10:12am UTC](https://www.ruby-forum.com/t/sending-thousands-of-email-with-ar-mailer/151512/1 "2008-10-22T10:12:51Z")

</div>

Hi,

to send an email with ar\_mailer I need to generate it and save it to  
the db, right?

Currently the code looks very simple:  
Newsletter.recepients.each do |recepient|  
NewsletterMailer.deliver\_dedicated(request, recepient, newsletter)  
end

But for i.e. 30000 receivers it’s going to take a long while anyway.  
Should I create them somehow in the background using BackgrounDRb or  
something similar? If I should, then I could get rid of the ar\_mailer  
and just send all emails in the background… The only advantage of  
ar\_mailer in this case would be the functionality to send emails in  
batches.

Any thoughts?

---

<div class="post-metadata">

**Author:** ![g0nzo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3bc359/32.png) [@g0nzo](https://www.ruby-forum.com/u/g0nzo)\
**Post date:** [October 22, 2008, 12:33pm UTC](https://www.ruby-forum.com/t/sending-thousands-of-email-with-ar-mailer/151512/2 "2008-10-22T12:33:42Z")

</div>

The use of backgroundrb is to divorse the long running the tasks from  
controllers.

if you use ar\_mailer you rails app will be overloaded. So its better to  
go with backgroundrb.

Cheers,  
Ratnavel.
