Forum: Ruby on Rails bulk email solutions

Cc1c1f4c3a354d578c709a602efa3b45?d=identicon&s=25 Aldo Italo (aldoitalo)
on 2009-08-20 22:51
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 ?
2505b282d57c29be797dc35b245adb4c?d=identicon&s=25 Philip Hallstrom (Guest)
on 2009-08-20 23:14
(Received via mailing list)
On Aug 20, 2009, at 1:51 PM, Aldo Italo 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
Cc1c1f4c3a354d578c709a602efa3b45?d=identicon&s=25 Aldo Italo (aldoitalo)
on 2009-08-20 23:21

> 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
2505b282d57c29be797dc35b245adb4c?d=identicon&s=25 Philip Hallstrom (Guest)
on 2009-08-20 23:35
(Received via mailing list)
>> 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
4ddf8432a838f716cc499e43131e5e58?d=identicon&s=25 James Englert (Guest)
on 2009-08-20 23:47
(Received via mailing list)
I've googled a bit and I can't seem to find it.  Could you do me a huge
favor and link me?!
2505b282d57c29be797dc35b245adb4c?d=identicon&s=25 Philip Hallstrom (Guest)
on 2009-08-20 23:57
(Received via mailing list)
On Aug 20, 2009, at 2:46 PM, James Englert 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...

http://github.com/rails/rails/blob/106976df0911e42...

-philip
56b7e1808013614acdb73cbaaa6938a1?d=identicon&s=25 Michael Pavling (Guest)
on 2010-12-10 07:45
(Received via mailing list)
On 10 December 2010 06:41, Samd Onna <lists@ruby-forum.com> wrote:
> Are desktop email address software products worth the money? <snip spam>

Are these messages supposed to be ironic?
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.