ActionMailer Multiple recipients

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[email protected]
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:
[email protected], [email protected] for the recipient would work as it does
for any email client.

Any ideas what’s wrong,
Thanks
Meenal

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

Thanks Fred, the commas were the problem.

On May 3, 10:06 am, Frederick C. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs