# Bulk email solutions

**URL:** <https://www.ruby-forum.com/t/bulk-email-solutions/174105>\
**Category:** Rails\
**Created:** [August 20, 2009, 10:51pm UTC](https://www.ruby-forum.com/t/bulk-email-solutions/174105 "2009-08-20T22:51:15Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![aldoitalo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@aldoitalo](https://www.ruby-forum.com/u/aldoitalo)\
**Post date:** [August 20, 2009, 10:51pm UTC](https://www.ruby-forum.com/t/bulk-email-solutions/174105/1 "2009-08-20T22:51:15Z")

</div>

i need to send massive emails to various customers,  
here 2 solutions i have think:

1-

customers = Customer.find(:all, :conditions =\> “newsletter = 1”)  
customers.each do |c|  
@email = c.email  
Mailer.deliver\_send\_newsletter(@subject, @email, @notice\_id)  
end

2-  
customers = Customer.find(:all, :conditions =\> “newsletter = 1”)  
customers.each do |c|  
addresses \<\< c.email+", "  
end  
@emails=addresses.join.gsub(/(, )$/, ‘’)  
Mailer.deliver\_send\_newsletter(@subject, @emails, @notice\_id)

what is the right solution ?

---

<div class="post-metadata">

**Author:** ![aldoitalo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@aldoitalo](https://www.ruby-forum.com/u/aldoitalo)\
**Post date:** [August 20, 2009, 11:14pm UTC](https://www.ruby-forum.com/t/bulk-email-solutions/174105/2 "2009-08-20T23:14:30Z")

</div>

On Aug 20, 2009, at 1:51 PM, Aldo I. wrote:

> Mailer.deliver\_send\_newsletter(@subject, @email, @notice\_id)
> 
> what is the right solution ?

Hard to say without knowing how many customers that query is going to  
return… if it’s under a 100 it doesn’t matter. Under a 1000 it  
probably doesn’t matter. If it’s 10,000 and it’s once a week, neither  
is going to be very fun. Keep in mind that those queries will  
instantiate however many objects that match… you could suck up a lot  
of memory… at least use the new find/block stuff.

Might want to look into ar\_mailer (ruby stuff), bulk\_mailer (stand  
alone) and if your volume is high one of the companies that does this  
for a living so you don’t have to deal with ending up on aol/msn/  
yahoo’s spam blacklists…

-philip

---

<div class="post-metadata">

**Author:** ![aldoitalo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@aldoitalo](https://www.ruby-forum.com/u/aldoitalo)\
**Post date:** [August 20, 2009, 11:21pm UTC](https://www.ruby-forum.com/t/bulk-email-solutions/174105/3 "2009-08-20T23:21:21Z")

</div>

> Hard to say without knowing how many customers that query is going to  
> return… if it’s under a 100 it doesn’t matter. Under a 1000 it  
> probably doesn’t matter.

i have under 500 customers

> of memory… at least use the new find/block stuff.

what is it?

thanks

---

<div class="post-metadata">

**Author:** ![aldoitalo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@aldoitalo](https://www.ruby-forum.com/u/aldoitalo)\
**Post date:** [August 20, 2009, 11:35pm UTC](https://www.ruby-forum.com/t/bulk-email-solutions/174105/4 "2009-08-20T23:35:00Z")

</div>

> > Hard to say without knowing how many customers that query is going to  
> > return… if it’s under a 100 it doesn’t matter. Under a 1000 it  
> > probably doesn’t matter.
> 
> i have under 500 customers

If it were me I’d email them each individually and customize the email  
to include their full name in the to field, a “hello Aldo” in the  
message, and a one-click unsubscribe url. Doesn’t matter how you send  
them with only 500.

> > of memory… at least use the new find/block stuff.
> 
> what is it?

I can never remember the exact syntax… it’s a new method that lets  
you issue a find and then iterate through it say 100 objects at a time  
– so that you aren’t building an array of 10,000 objects. Google  
around and you’ll find it.

-philip

---

<div class="post-metadata">

**Author:** ![aldoitalo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@aldoitalo](https://www.ruby-forum.com/u/aldoitalo)\
**Post date:** [August 20, 2009, 11:57pm UTC](https://www.ruby-forum.com/t/bulk-email-solutions/174105/5 "2009-08-20T23:57:50Z")

</div>

On Aug 20, 2009, at 2:46 PM, James E. wrote:

> I’ve googled a bit and I can’t seem to find it. Could you do me a  
> huge  
> favor and link me?!

find\_each is what it’s called…

> <https://github.com/rails/rails/blob/106976df0911e423042ec4abc165fd561766a047/activerecord/lib/active_record/batches.rb#L47>

-philip

---

<div class="post-metadata">

**Author:** ![aldoitalo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@aldoitalo](https://www.ruby-forum.com/u/aldoitalo)\
**Post date:** [December 10, 2010, 7:45am UTC](https://www.ruby-forum.com/t/bulk-email-solutions/174105/6 "2010-12-10T07:45:13Z")

</div>

On 10 December 2010 06:41, Samd O. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Are desktop email address software products worth the money?

Are these messages supposed to be ironic?

---

<div class="post-metadata">

**Author:** ![aldoitalo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@aldoitalo](https://www.ruby-forum.com/u/aldoitalo)\
**Post date:** [August 20, 2009, 11:47pm UTC](https://www.ruby-forum.com/t/bulk-email-solutions/174105/7 "2009-08-20T23:47:17Z")

</div>

I’ve googled a bit and I can’t seem to find it. Could you do me a huge  
favor and link me?!
