# ActionMailer Multiple recipients

**URL:** <https://www.ruby-forum.com/t/actionmailer-multiple-recipients/136555>\
**Category:** Rails\
**Created:** [May 3, 2008, 4:34pm UTC](https://www.ruby-forum.com/t/actionmailer-multiple-recipients/136555 "2008-05-03T16:34:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Meenal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@Meenal](https://www.ruby-forum.com/u/Meenal)\
**Post date:** [May 3, 2008, 4:34pm UTC](https://www.ruby-forum.com/t/actionmailer-multiple-recipients/136555/1 "2008-05-03T16:34:26Z")

</div>

I am using ActionMailer to send mails. I want to send mails to  
multiple recipients which I get from a view. Here is the controller  
code.

def groupcorres  
user = User.find(session[:user\_id])  
address = Array.new  
lines = Array.new  
args = params[:id].to\_s # params[:id] is an array of user screen  
name. ex: j\_doe, d\_john  
lines = args.split(“,”)  
for line in lines  
recipient = User.find\_by\_screen\_name(line)  
email = recipient.email.to\_s + “,”  
address \<\< email  
end  
if param\_posted?(:message)  
@message = Message.new(params[:message])  
if @message.valid?  
UserMailer.deliver\_groupmess(  
:user =\> user,  
:recipient =\> address,  
:message =\> @message,  
:user\_url =\> profile\_for(user),  
:reply\_url =\> url\_for(:action =\> “correspond”,  
:id =\> user.screen\_name)  
)  
flash[:notice] = “Email sent.”  
redirect\_to profile\_for(user)  
end  
end

and in models/user\_mailer.rb , I have

def groupmess(mail)  
subject mail[:message].subject  
from ’ Test[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)’  
recipients mail[:recipient]  
body mail  
end

This seems to work , but the recipients never receive any emails. Also  
I saw on the development log , that the"To" field on the email dump is  
missing. When I send the message to a single user , the “To” address  
is present.

I think that a string of comma separated email address ex:  
removed\_email\_address@domain.invalid, removed\_email\_address@domain.invalid for the recipient would work as it does  
for any email client.

Any ideas what’s wrong,  
Thanks  
Meenal

---

<div class="post-metadata">

**Author:** ![Meenal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@Meenal](https://www.ruby-forum.com/u/Meenal)\
**Post date:** [May 3, 2008, 5:06pm UTC](https://www.ruby-forum.com/t/actionmailer-multiple-recipients/136555/2 "2008-05-03T17:06:54Z")

</div>

On 3 May 2008, at 15:33, Meenal wrote:

> name. ex: j\_doe, d\_john  
> lines = args.split(",")  
> for line in lines  
> recipient = User.find\_by\_screen\_name(line)  
> email = recipient.email.to\_s + “,”  
> address \<\< email  
> You don’t need to add commas. that’s probably messing everything up.

Fred

---

<div class="post-metadata">

**Author:** ![Meenal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@Meenal](https://www.ruby-forum.com/u/Meenal)\
**Post date:** [May 3, 2008, 9:26pm UTC](https://www.ruby-forum.com/t/actionmailer-multiple-recipients/136555/3 "2008-05-03T21:26:40Z")

</div>

Thanks Fred, the commas were the problem.

On May 3, 10:06 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
