Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This idea won't scale much - you'd need to implement something like <code>Resque</code> and workers to process sending all the emails out.</p> <p>Yes, @socjopata's idea is good, but you'll really want to iterate adding them to the job queue and spawn a couple workers to process them. As per the guides, this is how to do it:</p> <pre><code>class AdminMailer &lt; ActionMailer::Base default :to =&gt; ["foo@bar.com", "bar@foo.com"], :from =&gt; "notification@example.com" def new_registration(user) @user = user mail(:subject =&gt; "New User Signup: #{@user.email}") end end </code></pre> <p>I'd essentially hand of <code>YourMailer.feedback_mail(&lt;PASS ARGS HERE&gt;).deliver</code> to Resque-</p> <pre><code>Resque.enqueue(SendMail, &lt;ARGS&gt;) # replace this in your controller </code></pre> <p>The worker would look like</p> <pre><code>#send_mail.rb class SendMail @queue = :feedback_mail_queue def self.perform(&lt;ARGS&gt;) # pass these in enqueue call YourMailer.feedback_mail(&lt;PASS ARGS HERE&gt;).deliver end end </code></pre> <p>As per <a href="http://guides.rubyonrails.org/action_mailer_basics.html#complete-list-of-action-mailer-methods" rel="nofollow">section 2.3.4</a> of the Rails Guides:</p> <blockquote> <p>It is possible to send email to one or more recipients in one email (for e.g. informing all admins of a new signup) by setting the list of emails to the :to key. The list of emails can be <strong>an array of email addresses or a single string</strong> with the addresses separated by commas.</p> </blockquote> <p>Looking back at your attempt, FYI - this should work</p> <pre><code>def feedback_mail @verteiler = ["foo@bar.com", "bar@foo.com"] mail(:to =&gt; @verteiler, :subject =&gt; "Foo Bar") end </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload