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<do-not-reply-J0of1frlU80@public.gmane.org>'' 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: user1-q89RzV0OsXQ@public.gmane.org, user2-bGHiYpY0Uss@public.gmane.org for the recipient would work as it does for any email client. Any ideas what''s wrong, Thanks Meenal --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
On 3 May 2008, at 15:33, Meenal wrote:> > 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 << emailYou don''t need to add commas. that''s probably messing everything up. Fred --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks Fred, the commas were the problem. On May 3, 10:06 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 3 May 2008, at 15:33, Meenal wrote: > > > > > > > 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 > > You don''t need to add commas. that''s probably messing everything up. > > Fred--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---