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 =>
''s@mama.com'', :name => ''aaa'' }, {:id
=> 454, :email => ''sjsl-lztva+7fudk@public.gmane.org'',
: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 => "yoni-A+lxSsK1Ony+XT7JhA+gdA@public.gmane.org"
)
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
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2006-Oct-17 11:23 UTC
Re: action mailer, error Subject: Header must not be multipl
You''re trying to set the subject of the email to an array, which clearly is not a reasonable thing to expect. Fred -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Yoni aa
2006-Oct-17 12:26 UTC
Re: action mailer, error Subject: Header must not be multipl
Frederick Cheung wrote:> You''re trying to set the subject of the email to an array, which clearly > is not a reasonable thing to expect. > > Fredcan you guide me? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2006-Oct-17 15:55 UTC
Re: action mailer, error Subject: Header must not be multipl
I''ve no idea what you want to set as the subject line of your email, but just don''t set it to be an array, i.e. set grouptitle to a string. If you want different subject lines for each emails I believe you''ll need to create emails one by one. Fred -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---