diff options
Diffstat (limited to 'actionmailer/lib/action_mailer/base.rb')
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 94 |
1 files changed, 39 insertions, 55 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index f00a0c8ae0..ac49702ced 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -1,5 +1,4 @@ require 'mail' -require 'action_mailer/tmail_compat' require 'action_mailer/collector' require 'active_support/core_ext/array/wrap' require 'active_support/core_ext/object/blank' @@ -23,16 +22,16 @@ module ActionMailer #:nodoc: # # Examples: # - # class Notifier < ActionMailer::Base - # default :from => 'no-reply@example.com', + # class Notifier < ActionMailer::Base + # default :from => 'no-reply@example.com', # :return_path => 'system@example.com' # - # def welcome(recipient) - # @account = recipient - # mail(:to => recipient.email_address_with_name, - # :bcc => ["bcc@example.com", "Order Watcher <watcher@example.com>"]) - # end - # end + # def welcome(recipient) + # @account = recipient + # mail(:to => recipient.email_address_with_name, + # :bcc => ["bcc@example.com", "Order Watcher <watcher@example.com>"]) + # end + # end # # Within the mailer method, you have access to the following methods: # @@ -58,7 +57,7 @@ module ActionMailer #:nodoc: # 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.text.plain.erb+ view + # the same name as the method, so the above action would send the +welcome.text.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: @@ -89,7 +88,7 @@ module ActionMailer #:nodoc: # # To define a template to be used with a mailing, create an <tt>.erb</tt> file with the same # name as the method in your mailer model. For example, in the mailer defined above, the template at - # <tt>app/views/notifier/signup_notification.text.plain.erb</tt> would be used to generate the email. + # <tt>app/views/notifier/welcome.text.erb</tt> would be used to generate the email. # # Variables defined in the model are accessible as instance variables in the view. # @@ -101,12 +100,12 @@ module ActionMailer #:nodoc: # You can even use Action Pack helpers in these views. For example: # # You got a new note! - # <%= truncate(@note.body, 25) %> + # <%= truncate(@note.body, :length => 25) %> # # If you need to access the subject, from or the recipients in the view, you can do that through message object: # # You got a new note from <%= message.from %>! - # <%= truncate(@note.body, 25) %> + # <%= truncate(@note.body, :length => 25) %> # # # = Generating URLs @@ -123,21 +122,19 @@ module ActionMailer #:nodoc: # # <%= users_url(:host => "example.com") %> # - # You want to avoid using the <tt>name_of_route_path</tt> form of named routes because it doesn't - # make sense to generate relative URLs in email messages. + # You should use the <tt>named_route_url</tt> style (which generates absolute URLs) and avoid using the + # <tt>named_route_path</tt> style (which generates relative URLs), since clients reading the mail will + # have no concept of a current URL from which to determine a relative path. # # 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>: # # config.action_mailer.default_url_options = { :host => "example.com" } # - # Setting <tt>ActionMailer::Base.default_url_options</tt> directly is now deprecated, use the configuration - # option mentioned above to set the default host. - # - # If you do decide to set a default <tt>:host</tt> for your mailers you want to use the - # <tt>:only_path => false</tt> option when using <tt>url_for</tt>. This will ensure that absolute URLs are - # generated because the <tt>url_for</tt> view helper will, by default, generate relative URLs when a - # <tt>:host</tt> option isn't explicitly provided. + # When you decide to set a default <tt>:host</tt> for your mailers, then you need to make sure to use the + # <tt>:only_path => false</tt> option when using <tt>url_for</tt>. Since the <tt>url_for</tt> view helper + # will generate relative URLs by default when a <tt>:host</tt> option isn't explicitly provided, passing + # <tt>:only_path => false</tt> will ensure that absolute URLs are generated. # # = Sending mail # @@ -152,12 +149,12 @@ module ActionMailer #:nodoc: # # = Multipart Emails # - # Multipart messages can also be used implicitly because Action Mailer will automatically - # detect and use multipart templates, where each template is named after the name of the action, followed - # by the content type. Each such detected template will be added as separate part to the message. + # Multipart messages can also be used implicitly because Action Mailer will automatically detect and use + # multipart templates, where each template is named after the name of the action, followed by the content + # type. Each such detected template will be added as a separate part to the message. # # For example, if the following templates exist: - # * signup_notification.text.plain.erb + # * signup_notification.text.erb # * signup_notification.text.html.erb # * signup_notification.text.xml.builder # * signup_notification.text.yaml.erb @@ -182,7 +179,7 @@ module ActionMailer #:nodoc: # end # end # - # Which will (if it had both a <tt>welcome.text.plain.erb</tt> and <tt>welcome.text.html.erb</tt> + # Which will (if it had both a <tt>welcome.text.erb</tt> and <tt>welcome.text.html.erb</tt> # template in the view directory), send a complete <tt>multipart/mixed</tt> email with two parts, # the first part being a <tt>multipart/alternative</tt> with the text and HTML email parts inside, # and the second being a <tt>application/pdf</tt> with a Base64 encoded copy of the file.pdf book @@ -216,15 +213,15 @@ module ActionMailer #:nodoc: # # = Observing and Intercepting Mails # - # Action Mailer provides hooks into the Mail observer and interceptor methods. These allow you to - # register objects that are called during the mail delivery life cycle. + # Action Mailer provides hooks into the Mail observer and interceptor methods. These allow you to + # register classes that are called during the mail delivery life cycle. # - # An observer object must implement the <tt>:delivered_email(message)</tt> method which will be + # An observer class must implement the <tt>:delivered_email(message)</tt> method which will be # called once for every email sent after the email has been sent. # - # An interceptor object must implement the <tt>:delivering_email(message)</tt> method which will be + # An interceptor class must implement the <tt>:delivering_email(message)</tt> method which will be # called before the email is sent, allowing you to make modifications to the email before it hits - # the delivery agents. Your object should make any needed modifications directly to the passed + # the delivery agents. Your class should make any needed modifications directly to the passed # in Mail::Message instance. # # = Default Hash @@ -297,9 +294,9 @@ module ActionMailer #:nodoc: # information and a cryptographic Message Digest 5 algorithm to hash important information) # * <tt>:enable_starttls_auto</tt> - When set to true, detects if STARTTLS is enabled in your SMTP server # and starts to use it. - # * <tt>:openssl_verify_mode</tt> - When using TLS, you can set how OpenSSL checks the certificate. This is - # really useful if you need to validate a self-signed and/or a wildcard certificate. You can use the name - # of an OpenSSL verify constant ('none', 'peer', 'client_once','fail_if_no_peer_cert') or directly the + # * <tt>:openssl_verify_mode</tt> - When using TLS, you can set how OpenSSL checks the certificate. This is + # really useful if you need to validate a self-signed and/or a wildcard certificate. You can use the name + # of an OpenSSL verify constant ('none', 'peer', 'client_once','fail_if_no_peer_cert') or directly the # constant (OpenSSL::SSL::VERIFY_NONE, OpenSSL::SSL::VERIFY_PEER,...). # # * <tt>sendmail_settings</tt> - Allows you to override options for the <tt>:sendmail</tt> delivery method. @@ -315,29 +312,16 @@ module ActionMailer #:nodoc: # # * <tt>delivery_method</tt> - Defines a delivery method. Possible values are <tt>:smtp</tt> (default), # <tt>:sendmail</tt>, <tt>:test</tt>, and <tt>:file</tt>. Or you may provide a custom delivery method - # object eg. MyOwnDeliveryMethodClass.new. See the Mail gem documentation on the interface you need to + # object eg. MyOwnDeliveryMethodClass.new. See the Mail gem documentation on the interface you need to # implement for a custom delivery agent. # # * <tt>perform_deliveries</tt> - Determines whether emails are actually sent from Action Mailer when you - # call <tt>.deliver</tt> on an mail message or on an Action Mailer method. This is on by default but can + # call <tt>.deliver</tt> 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. # # * <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> - This is now deprecated, use the +default+ method above to - # set the default +:charset+. - # - # * <tt>default_content_type</tt> - This is now deprecated, use the +default+ method above - # to set the default +:content_type+. - # - # * <tt>default_mime_version</tt> - This is now deprecated, use the +default+ method above - # to set the default +:mime_version+. - # - # * <tt>default_implicit_parts_order</tt> - This is now deprecated, use the +default+ 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 abstract! @@ -352,7 +336,6 @@ module ActionMailer #:nodoc: self.protected_instance_variables = %w(@_action_has_layout) helper ActionMailer::MailHelper - include ActionMailer::OldApi private_class_method :new #:nodoc: @@ -383,8 +366,8 @@ module ActionMailer #:nodoc: Mail.register_observer(delivery_observer) end - # Register an Inteceptor which will be called before mail is sent. - # Either a class or a string can be passed in as the Observer. If a string is passed in + # Register an Interceptor which will be called before mail is sent. + # Either a class or a string can be passed in as the Interceptor. If a string is passed in # it will be <tt>constantize</tt>d. def register_interceptor(interceptor) delivery_interceptor = (interceptor.is_a?(String) ? interceptor.constantize : interceptor) @@ -567,8 +550,8 @@ module ActionMailer #:nodoc: # method. # # When a <tt>:return_path</tt> is specified as header, that value will be used as the 'envelope from' - # address for the Mail message. Setting this is useful when you want delivery notifications - # sent to a different address than the one in <tt>:from</tt>. Mail will actually use the + # address for the Mail message. Setting this is useful when you want delivery notifications + # sent to a different address than the one in <tt>:from</tt>. Mail will actually use the # <tt>:return_path</tt> in preference to the <tt>:sender</tt> in preference to the <tt>:from</tt> # field for the 'envelope from' value. # @@ -750,3 +733,4 @@ module ActionMailer #:nodoc: ActiveSupport.run_load_hooks(:action_mailer, self) end end + |