aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/source/action_mailer_basics.textile
diff options
context:
space:
mode:
authorAditya Sanghi <asanghi@me.com>2010-09-25 14:31:19 +0530
committerAditya Sanghi <asanghi@me.com>2010-09-25 14:31:19 +0530
commitc94e92e2b080ef824bc63dae771173fd4f57e28e (patch)
tree8a77a06d8d77142a1f8169b134eda2176e118c4e /railties/guides/source/action_mailer_basics.textile
parentb1603990dfc09eb8452169954f54e2af2cb7e0e6 (diff)
downloadrails-c94e92e2b080ef824bc63dae771173fd4f57e28e.tar.gz
rails-c94e92e2b080ef824bc63dae771173fd4f57e28e.tar.bz2
rails-c94e92e2b080ef824bc63dae771173fd4f57e28e.zip
Add section about multiple recipients
Diffstat (limited to 'railties/guides/source/action_mailer_basics.textile')
-rw-r--r--railties/guides/source/action_mailer_basics.textile17
1 files changed, 17 insertions, 0 deletions
diff --git a/railties/guides/source/action_mailer_basics.textile b/railties/guides/source/action_mailer_basics.textile
index 8eb48e2751..16e611f285 100644
--- a/railties/guides/source/action_mailer_basics.textile
+++ b/railties/guides/source/action_mailer_basics.textile
@@ -242,6 +242,23 @@ end
:class => 'photos' %>
</erb>
+h5. Sending email to multiple recipients
+
+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 <tt>:to</tt> key. The <tt>to:</tt> key however expects a string so you have join the list of recipients using a comma.
+
+<ruby>
+ Class AdminMailer < ActionMailer::Base
+ default :to => Admin.all.map{|admin| admin.email}.join(", "),
+ :from => "notification@example.com"
+
+ def new_registration(user)
+ @user = user
+ mail(:subject => "New User Signup: #{@user.email}")
+ end
+ end
+</ruby>
+
+
h4. Mailer Views
Mailer views are located in the +app/views/name_of_mailer_class+ directory. The specific mailer view is known to the class because it's name is the same as the mailer method. So for example, in our example from above, our mailer view for the +welcome_email+ method will be in +app/views/user_mailer/welcome_email.html.erb+ for the HTML version and +welcome_email.text.erb+ for the plain text version.