aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/source/action_mailer_basics.textile
diff options
context:
space:
mode:
authorSergey Parizhskiy <parizhskiy@gmail.com>2011-11-28 17:33:23 +0200
committerSergey Parizhskiy <parizhskiy@gmail.com>2011-11-28 17:33:23 +0200
commite2e2d6298ebd9c67d0dc14c1e3481a59a4edf5d2 (patch)
tree83297628700ed0dc8ac8bdfb60aae8645a517c32 /railties/guides/source/action_mailer_basics.textile
parent493cf44682c19bd69eb2463d260c3bf29c7a23d7 (diff)
parent6d05c793cafe79860bcbb469d6c46c83c531ab34 (diff)
downloadrails-e2e2d6298ebd9c67d0dc14c1e3481a59a4edf5d2.tar.gz
rails-e2e2d6298ebd9c67d0dc14c1e3481a59a4edf5d2.tar.bz2
rails-e2e2d6298ebd9c67d0dc14c1e3481a59a4edf5d2.zip
Merge branch 'master' of github.com:lifo/docrails
Diffstat (limited to 'railties/guides/source/action_mailer_basics.textile')
-rw-r--r--railties/guides/source/action_mailer_basics.textile15
1 files changed, 4 insertions, 11 deletions
diff --git a/railties/guides/source/action_mailer_basics.textile b/railties/guides/source/action_mailer_basics.textile
index ad5b848d2c..26c95be031 100644
--- a/railties/guides/source/action_mailer_basics.textile
+++ b/railties/guides/source/action_mailer_basics.textile
@@ -362,21 +362,14 @@ When using named routes you only need to supply the +:host+:
Email clients have no web context and so paths have no base URL to form complete web addresses. Thus, when using named routes only the "_url" variant makes sense.
-It is also possible to set a default host that will be used in all mailers by setting the +:host+ option in the +ActionMailer::Base.default_url_options+ hash as follows:
+It is also possible to set a default host that will be used in all mailers by setting the <tt>:host</tt> option as a configuration option in <tt>config/application.rb</tt>:
<ruby>
-class UserMailer < ActionMailer::Base
- default_url_options[:host] = "example.com"
-
- def welcome_email(user)
- @user = user
- @url = user_url(@user)
- mail(:to => user.email,
- :subject => "Welcome to My Awesome Site")
- end
-end
+config.action_mailer.default_url_options = { :host => "example.com" }
</ruby>
+If you use this setting, you should pass the <tt>:only_path => false</tt> option when using +url_for+. This will ensure that absolute URLs are generated because the +url_for+ view helper will, by default, generate relative URLs when a <tt>:host</tt> option isn't explicitly provided.
+
h4. Sending Multipart Emails
Action Mailer will automatically send multipart emails if you have different templates for the same action. So, for our UserMailer example, if you have +welcome_email.text.erb+ and +welcome_email.html.erb+ in +app/views/user_mailer+, Action Mailer will automatically send a multipart email with the HTML and text versions setup as different parts.