diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb
index 6246530bf0..087f345c3f 100644
--- a/actionmailer/lib/action_mailer/base.rb
+++ b/actionmailer/lib/action_mailer/base.rb
@@ -38,8 +38,12 @@ module ActionMailer #:nodoc:
# * attachments[]= - Allows you to add attachments to your email in an intuitive
# manner; attachments['filename.png'] = File.read('path/to/filename.png')
#
- # * headers[]= - Allows you to specify non standard headers in your email such
- # as headers['X-No-Spam'] = 'True'
+ # * headers[]= - Allows you to specify any header field in your email such
+ # as headers['X-No-Spam'] = 'True'. Note, while most fields (like To:
+ # From: can only appear once in an email header, other fields like X-Anything
+ # can appear multiple times. If you want to change a field that can appear multiple times,
+ # you need to set it to nil first so that Mail knows you are replacing it, not adding
+ # another field of the same name.)
#
# * headers(hash) - Allows you to specify multiple headers in your email such
# as headers({'X-No-Spam' => 'True', 'In-Reply-To' => '1234@message.id'})
@@ -47,15 +51,11 @@ module ActionMailer #:nodoc:
# * mail - Allows you to specify your email to send.
#
# 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.)
+ # will accept (any valid Email header including optional fields).
#
# 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
- # as well as the +welcome.html.erb+ view file in a +multipart/alternative+ email.
+ # the same name as the method, so the above action would send the +welcome.text.plain.erb+ view
+ # file as well as the +welcome.text.html.erb+ view file in a +multipart/alternative+ email.
#
# If you want to explicitly render only certain templates, pass a block:
#
@@ -71,7 +71,7 @@ module ActionMailer #:nodoc:
# format.html
# end
#
- # Or even to renderize a special view:
+ # Or even to render a special view:
#
# mail(:to => user.emai) do |format|
# format.text
@@ -85,7 +85,7 @@ module ActionMailer #:nodoc:
#
# To define a template to be used with a mailing, create an .erb file with the same
# name as the method in your mailer model. For example, in the mailer defined above, the template at
- # app/views/notifier/signup_notification.text.erb would be used to generate the email.
+ # app/views/notifier/signup_notification.text.plain.erb would be used to generate the email.
#
# Variables defined in the model are accessible as instance variables in the view.
#
@@ -107,9 +107,9 @@ module ActionMailer #:nodoc:
#
# = Generating URLs
#
- # URLs can be generated in mailer views using url_for or named routes.
- # Unlike controllers from Action Pack, the mailer instance doesn't have any context about the incoming request,
- # so you'll need to provide all of the details needed to generate a URL.
+ # URLs can be generated in mailer views using url_for or named routes. Unlike controllers from
+ # Action Pack, the mailer instance doesn't have any context about the incoming request, so you'll need
+ # to provide all of the details needed to generate a URL.
#
# When using url_for you'll need to provide the :host, :controller, and :action:
#
@@ -119,11 +119,11 @@ module ActionMailer #:nodoc:
#
# <%= users_url(:host => "example.com") %>
#
- # You will want to avoid using the name_of_route_path form of named routes because it doesn't make sense to
- # generate relative URLs in email messages.
+ # You will want to avoid using the name_of_route_path form of named routes because it doesn't
+ # make sense to generate relative URLs in email messages.
#
- # 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 :host
+ # option in the ActionMailer::Base.default_url_options hash as follows:
#
# ActionMailer::Base.default_url_options[:host] = "example.com"
#
@@ -132,9 +132,9 @@ module ActionMailer #:nodoc:
# config.action_mailer.default_url_options = { :host => "example.com" }
#
# If you do decide to set a default :host for your mailers you will want to use the
- # :only_path => false 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 :host option isn't
- # explicitly provided.
+ # :only_path => false 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
+ # :host option isn't explicitly provided.
#
# = Sending mail
#
@@ -145,7 +145,7 @@ module ActionMailer #:nodoc:
# mail = Notifier.welcome(david) # => a Mail::Message object
# mail.deliver # sends the email
#
- # You never instantiate your mailer class. Rather, you just call the method on the class itself.
+ # You never instantiate your mailer class. Rather, you just call the method you defined on the class itself.
#
# = Multipart Emails
#
@@ -180,11 +180,11 @@ module ActionMailer #:nodoc:
# end
# end
#
- # Which will (if it had both a .text.erb and .html.erb tempalte in the view
- # directory), send a complete multipart/mixed email with two parts, the first part being
- # a multipart/alternative with the text and HTML email parts inside, and the second being
- # a application/pdf with a Base64 encoded copy of the file.pdf book with the filename
- # +free_book.pdf+.
+ # Which will (if it had both a welcome.text.plain.erb and welcome.text.html.erb
+ # tempalte in the view directory), send a complete multipart/mixed email with two parts,
+ # the first part being a multipart/alternative with the text and HTML email parts inside,
+ # and the second being a application/pdf with a Base64 encoded copy of the file.pdf book
+ # with the filename +free_book.pdf+.
#
#
# = Configuration options
@@ -194,7 +194,9 @@ module ActionMailer #:nodoc:
# * default - This is a class wide hash of :key => value pairs containing
# default values for the specified header fields of the Mail::Message. You can
# specify a default for any valid header for Mail::Message and it will be used if
- # you do not override it. The defaults set by Action Mailer are:
+ # you do not override it. You pass in the header value as a symbol, all lower case with under
+ # scores instead of hyphens, so Content-Transfer-Encoding:
+ # becomes :content_transfer_encoding. The defaults set by Action Mailer are:
# * :mime_version => "1.0"
# * :charset => "utf-8",
# * :content_type => "text/plain",
@@ -204,33 +206,40 @@ module ActionMailer #:nodoc:
# Can be set to nil for no logging. Compatible with both Ruby's own Logger and Log4r loggers.
#
# * smtp_settings - Allows detailed configuration for :smtp delivery method:
- # * :address - Allows you to use a remote mail server. Just change it from its default "localhost" setting.
+ # * :address - Allows you to use a remote mail server. Just change it from its default
+ # "localhost" setting.
# * :port - On the off chance that your mail server doesn't run on port 25, you can change it.
# * :domain - If you need to specify a HELO domain, you can do it here.
# * :user_name - If your mail server requires authentication, set the username in this setting.
# * :password - If your mail server requires authentication, set the password in this setting.
- # * :authentication - If your mail server requires authentication, you need to specify the authentication type here.
+ # * :authentication - If your mail server requires authentication, you need to specify the
+ # authentication type here.
# This is a symbol and one of :plain, :login, :cram_md5.
- # * :enable_starttls_auto - When set to true, detects if STARTTLS is enabled in your SMTP server and starts to use it.
- # It works only on Ruby >= 1.8.7 and Ruby >= 1.9. Default is true.
+ # * :enable_starttls_auto - When set to true, detects if STARTTLS is enabled in your SMTP server
+ # and starts to use it.
#
# * sendmail_settings - Allows you to override options for the :sendmail delivery method.
# * :location - The location of the sendmail executable. Defaults to /usr/sbin/sendmail.
- # * :arguments - The command line arguments. Defaults to -i -t.
+ # * :arguments - The command line arguments. Defaults to -i -t with -f sender@addres
+ # added automatically before the message is sent.
#
# * file_settings - Allows you to override options for the :file delivery method.
- # * :location - The directory into which emails will be written. Defaults to the application tmp/mails.
+ # * :location - The directory into which emails will be written. Defaults to the application
+ # tmp/mails.
#
# * raise_delivery_errors - Whether or not errors should be raised if the email fails to be delivered.
#
- # * delivery_method - Defines a delivery method. Possible values are :smtp (default), :sendmail, :test,
- # and :file. Or you may provide a custom delivery method object eg. MyOwnDeliveryMethodClass.new
+ # * delivery_method - Defines a delivery method. Possible values are :smtp (default),
+ # :sendmail, :test, and :file. Or you may provide a custom delivery method
+ # object eg. MyOwnDeliveryMethodClass.new. See the Mail gem documentation on the interface you need to
+ # implement for a custom delivery agent.
#
- # * perform_deliveries - Determines whether deliver_* methods are actually carried out. By default they are,
- # but this can be turned off to help functional testing.
+ # * perform_deliveries - Determines whether emails are actually sent from Action Mailer when you
+ # call .deliver on an mail message or on an Action Mailer method. This is on by default but can
+ # be turned off to aid in functional testing.
#
- # * deliveries - Keeps an array of all the emails sent out through the Action Mailer with delivery_method :test. Most useful
- # for unit and functional testing.
+ # * deliveries - Keeps an array of all the emails sent out through the Action Mailer with
+ # delivery_method :test. Most useful for unit and functional testing.
#
# * default_charset - This is now deprecated, use the +default+ method above to
# set the default +:charset+.
@@ -289,7 +298,7 @@ module ActionMailer #:nodoc:
# instantiates a new mailer, and passes the email object to the mailer
# object's +receive+ method. If you want your mailer to be able to
# process incoming messages, you'll need to implement a +receive+
- # method that accepts the email object as a parameter:
+ # method that accepts the raw email string as a parameter:
#
# class MyMailer < ActionMailer::Base
# def receive(mail)
@@ -304,9 +313,10 @@ module ActionMailer #:nodoc:
end
end
- # Delivers a mail object. This is actually called by the Mail::Message object
- # itself through a call back when you call :deliver on the Mail::Message,
- # calling +deliver_mail+ directly and passing an Mail::Message will do nothing.
+ # Wraps an email delivery inside of Active Support Notifications instrumentation. This
+ # method is actually called by the Mail::Message object itself through a call back
+ # when you call :deliver on the Mail::Message, calling +deliver_mail+ directly
+ # and passing a Mail::Message will do nothing except tell the logger you sent the email.
def deliver_mail(mail) #:nodoc:
ActiveSupport::Notifications.instrument("action_mailer.deliver") do |payload|
self.set_payload_for_mail(payload, mail)
diff --git a/actionmailer/lib/action_mailer/delivery_methods.rb b/actionmailer/lib/action_mailer/delivery_methods.rb
index f6321a240c..7e92aea8fd 100644
--- a/actionmailer/lib/action_mailer/delivery_methods.rb
+++ b/actionmailer/lib/action_mailer/delivery_methods.rb
@@ -2,7 +2,7 @@ require 'tmpdir'
module ActionMailer
# This modules handles everything related to the delivery, from registering new
- # delivery methods to configuring the mail object to be send.
+ # delivery methods to configuring the mail object to be sent.
module DeliveryMethods
extend ActiveSupport::Concern
diff --git a/actionmailer/lib/action_mailer/quoting.rb b/actionmailer/lib/action_mailer/quoting.rb
index b30441f9de..70f636bf69 100644
--- a/actionmailer/lib/action_mailer/quoting.rb
+++ b/actionmailer/lib/action_mailer/quoting.rb
@@ -1,5 +1,8 @@
module ActionMailer
module Quoting #:nodoc:
+ # TODO extract this into Mail itself.
+ #
+ #
# Convert the given text into quoted printable format, with an instruction
# that the text be eventually interpreted in the given charset.
def quoted_printable(text, charset)