aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/lib/action_mailer
diff options
context:
space:
mode:
Diffstat (limited to 'actionmailer/lib/action_mailer')
-rw-r--r--actionmailer/lib/action_mailer/base.rb57
1 files changed, 35 insertions, 22 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb
index 95c45ec54b..f677ab629e 100644
--- a/actionmailer/lib/action_mailer/base.rb
+++ b/actionmailer/lib/action_mailer/base.rb
@@ -23,7 +23,7 @@ module ActionMailer #:nodoc:
# Examples:
#
# class Notifier < ActionMailer::Base
- # delivers_from 'system@example.com'
+ # defaults({:from => 'system@example.com'})
#
# def welcome(recipient)
# @account = recipient
@@ -40,13 +40,17 @@ module ActionMailer #:nodoc:
# * <tt>headers[]=</tt> - Allows you to specify non standard headers in your email such
# as <tt>headers['X-No-Spam'] = 'True'</tt>
#
+ # * <tt>headers(hash)</tt> - Allows you to specify multiple headers in your email such
+ # as <tt>headers({'X-No-Spam' => 'True', 'In-Reply-To' => '1234@message.id'})</tt>
+ #
# * <tt>mail</tt> - Allows you to specify your email to send.
#
- # The hash passed to the mail method allows you to specify the most used headers in an email
- # message, such as <tt>Subject</tt>, <tt>To</tt>, <tt>From</tt>, <tt>Cc</tt>, <tt>Bcc</tt>,
- # <tt>Reply-To</tt> and <tt>Date</tt>. See the <tt>ActionMailer#mail</tt> method for more details.
- #
- # If you need other headers not listed above, use the <tt>headers['name'] = value</tt> method.
+ # The hash passed to the mail method allows you to specify any header that a Mail::Message
+ # will accept (any valid Email header including optional fields). Obviously if you specify
+ # the same header in the headers method and then again in the mail method, the last one
+ # will over write the first, unless you are specifying a header field that can appear more
+ # than once per RFC, in which case, both will be inserted (X-value headers for example can
+ # appear multiple times.)
#
# The mail method, if not passed a block, will inspect your views and send all the views with
# the same name as the method, so the above action would send the +welcome.plain.erb+ view file
@@ -186,9 +190,14 @@ module ActionMailer #:nodoc:
#
# These options are specified on the class level, like <tt>ActionMailer::Base.template_root = "/my/templates"</tt>
#
- # * <tt>delivers_from</tt> - Pass this the address that then defaults as the +from+ address on all the
- # emails sent. Can be overridden on a per mail basis by passing <tt>:from => 'another@address'</tt> in
- # the +mail+ method.
+ # * <tt>defaults</tt> - This is a class wide hash of <tt>:key => value</tt> pairs containing
+ # default values for the specified header fields of the <tt>Mail::Message</tt>. You can
+ # specify a default for any valid header for <tt>Mail::Message</tt> and it will be used if
+ # you do not override it. The defaults set by Action Mailer are:
+ # * <tt>:mime_version => "1.0"</tt>
+ # * <tt>:charset => "utf-8",</tt>
+ # * <tt>:content_type => "text/plain",</tt>
+ # * <tt>:parts_order => [ "text/plain", "text/enriched", "text/html" ]</tt>
#
# * <tt>logger</tt> - the logger is used for generating information on the mailing run if available.
# Can be set to nil for no logging. Compatible with both Ruby's own Logger and Log4r loggers.
@@ -222,20 +231,19 @@ module ActionMailer #:nodoc:
# * <tt>deliveries</tt> - Keeps an array of all the emails sent out through the Action Mailer with <tt>delivery_method :test</tt>. Most useful
# for unit and functional testing.
#
- # * <tt>default_charset</tt> - The default charset used for the body and to encode the subject. Defaults to UTF-8. You can also
- # pick a different charset from inside a method with +charset+.
+ # * <tt>default_charset</tt> - This is now deprecated, use the +defaults+ method above to
+ # set the default +:charset+.
#
- # * <tt>default_content_type</tt> - The default content type used for the main part of the message. Defaults to "text/plain". You
- # can also pick a different content type from inside a method with +content_type+.
+ # * <tt>default_content_type</tt> - This is now deprecated, use the +defaults+ method above
+ # to set the default +:content_type+.
#
- # * <tt>default_mime_version</tt> - The default mime version used for the message. Defaults to <tt>1.0</tt>. You
- # can also pick a different value from inside a method with +mime_version+.
+ # * <tt>default_mime_version</tt> - This is now deprecated, use the +defaults+ method above
+ # to set the default +:mime_version+.
#
- # * <tt>default_implicit_parts_order</tt> - When a message is built implicitly (i.e. multiple parts are assembled from templates
- # which specify the content type in their filenames) this variable controls how the parts are ordered. Defaults to
- # <tt>["text/html", "text/enriched", "text/plain"]</tt>. Items that appear first in the array have higher priority in the mail client
- # and appear last in the mime encoded message. You can also pick a different order from inside a method with
- # +implicit_parts_order+.
+ # * <tt>default_implicit_parts_order</tt> - This is now deprecated, use the +defaults+ method above
+ # to set the default +:parts_order+. Parts Order is used when a message is built implicitly
+ # (i.e. multiple parts are assembled from templates which specify the content type in their
+ # filenames) this variable controls how the parts are ordered.
class Base < AbstractController::Base
include DeliveryMethods, Quoting
abstract!
@@ -348,13 +356,18 @@ module ActionMailer #:nodoc:
#
# headers['X-Special-Domain-Specific-Header'] = "SecretValue"
#
+ # You can also pass a hash into headers of header field names and values, which
+ # will then be set on the Mail::Message object:
+ #
+ # headers {'X-Special-Domain-Specific-Header' => "SecretValue",
+ # 'In-Reply-To' => incoming.message_id }
+ #
# The resulting Mail::Message will have the following in it's header:
#
# X-Special-Domain-Specific-Header: SecretValue
def headers(args=nil)
if args
- ActiveSupport::Deprecation.warn "headers(Hash) is deprecated, please do headers[key] = value instead", caller[0,2]
- @headers = args
+ @_message.headers(args)
else
@_message
end