# Action mailer, error Subject: Header must not be multiple

**URL:** <https://www.ruby-forum.com/t/action-mailer-error-subject-header-must-not-be-multiple/72469>\
**Category:** Rails\
**Created:** [October 17, 2006, 1:03pm UTC](https://www.ruby-forum.com/t/action-mailer-error-subject-header-must-not-be-multiple/72469 "2006-10-17T13:03:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/ee59a6/32.png) [@yoni](https://www.ruby-forum.com/u/yoni)\
**Post date:** [October 17, 2006, 1:03pm UTC](https://www.ruby-forum.com/t/action-mailer-error-subject-header-must-not-be-multiple/72469/1 "2006-10-17T13:03:43Z")

</div>

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 =\>  
‘removed\_email\_address@domain.invalid’, :name =\> ‘aaa’ }, {:id =\> 454, :email =\> ‘removed\_email\_address@domain.invalid’,  
: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 => "removed_email_address@domain.invalid"
    )
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

---

<div class="post-metadata">

**Author:** ![yoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/ee59a6/32.png) [@yoni](https://www.ruby-forum.com/u/yoni)\
**Post date:** [October 17, 2006, 1:23pm UTC](https://www.ruby-forum.com/t/action-mailer-error-subject-header-must-not-be-multiple/72469/2 "2006-10-17T13:23:03Z")

</div>

You’re trying to set the subject of the email to an array, which clearly  
is not a reasonable thing to expect.

Fred

---

<div class="post-metadata">

**Author:** ![yoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/ee59a6/32.png) [@yoni](https://www.ruby-forum.com/u/yoni)\
**Post date:** [October 17, 2006, 2:26pm UTC](https://www.ruby-forum.com/t/action-mailer-error-subject-header-must-not-be-multiple/72469/3 "2006-10-17T14:26:39Z")

</div>

Frederick C. wrote:

> You’re trying to set the subject of the email to an array, which clearly  
> is not a reasonable thing to expect.
> 
> Fred

can you guide me?

---

<div class="post-metadata">

**Author:** ![yoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/ee59a6/32.png) [@yoni](https://www.ruby-forum.com/u/yoni)\
**Post date:** [October 17, 2006, 5:55pm UTC](https://www.ruby-forum.com/t/action-mailer-error-subject-header-must-not-be-multiple/72469/4 "2006-10-17T17:55:56Z")

</div>

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
