Sending email to multiple recipients

   I have to send mail to multiple recipients. My table is named people
and has
first_name,last_name, email1 , email2, email3 for each person. i have
put people in various mailinglist .For example first mailinglist where
first_name is john or say the second mailing list contains people of
british origin.etc

Just a matter of opinion, but you might consider moving your email addresses to another table so you don't have to limit your users to three. I like to use a construct called "contact number" which can be a phone number (landline or cell), fax, email, page, url, im, whatever. Then you can have as many as you want and iterate through them as a collection. But that's just a matter of style and need.

the relation between mailinglist and people is many to many.
params[:ml] gives me the id of the mailing list to which mail is to be
In the controller i have

def sendmail
  @mailinglists.each do |ml|
  @people =

In the mailer model which i have named as user_mailer i have

class UserMailer < ActionMailer::Base
  def send_mail(people)
    recipients people.email1
# this generates error undefined method email1

recipients is an array, so you need to build all of the addresses as an array. The collection people does not have a method called "email1", that is an attribute of each person object. So you'd need to do something like this

people.each do |person|
  # this is more personal than just the email address, but that would work too
  recipients << "#{person.first_name} #{person.last_name} <#{person.email1}>"

I don't know about the performance of ActionMailer with thousands of recipients, so Bala's advice might be your best bet. And I would not use Jochen's advice (absolutely no offense intended, Jochen!) and put each delivery in a loop. In that case, you'd be sending a single message for every recipient instead of sending one message to your outbound server and letting it handle the multiple recipients.

Oh, one other thing: use bcc instead of recipients. It's generally considered bad etiquette to send out a mass email and put everyone's address in the to line.


Sorry, I can't be of much help here. I have not yet had a need such as this and therefore have no experience working it out. I'm sure that someone else on here will have some great ideas, though.


hi there
What I did was to use the fckeditor a js script editor which is easily
integrated with rails.
This editor has an option PASTE FROM WORD that keeps "some" of the
formatting (tables and other
stuff) it has worked wonderully for me