i want to send multiple emails:
#my Controller
def send_email
if params[:group_ids]
groups = Group.find(params[:group_ids]) # creates an array called
‘groups’ that looks like : [{:id => 1, :title => ‘yediot’}, {:id => 2,
:title => ‘maariv’} ] — [ 1, 2 ]
else
groups = []
end
names = []
emails = []
grouptitle = []
pages = []
groups.each { |group| # do a loop for {:id=> 1 …} and then do
another loop {:id => 2 … } until the end of the array, and then
continue to the next line # group.users - - > [{:id => 3, :email =>
‘[email protected]’, :name => ‘aaa’ }, {:id => 454, :email => ‘[email protected]’,
:name => ‘lsls’ }]
group.users.each {|a|
emails << a.email
names << a.name
}
groups.each { |group |
grouptitle << group.title
}
groups.each { |group|
group.pages.each {|page|
pages << page.body
}}
}
Mailer.deliver_contact_us(
:recipients => emails,
:subject => grouptitle, #the error comes from this line
:body => { :name => names,
:phone => '08-9492332',
:email => emails,
:message => pages,
},
:from => "[email protected]"
)
end
#my email Model(mailer.rb)
class Mailer < ActionMailer::Base
helper ActionView::Helpers::UrlHelper
def generic_mailer(options)
@recipients = options[:recipients]
@from = options[:from]
@cc = options[:cc] || “”
@bcc = options[:bcc] || “”
@subject = options[:subject] || “this is my great message”
@body = options[:body] || {}
@headers = options[:headers] || {}
@charset = options[:charset] || “utf-8”
end
Create placeholders for whichever e-mails you need to deal with.
Override mail elements where necessary
def contact_us(options)
self.generic_mailer(options)
end
end
rails error message: “Subject: Header must not be multiple”
**has anyone encounter this error???
thanks