diff options
author | Joshua Peek <josh@joshpeek.com> | 2008-05-14 14:09:49 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2008-05-14 14:09:49 -0500 |
commit | 3b0e1d90938e3d4c98830e037b3da15b3f736f7f (patch) | |
tree | 6e57d3b855939aa800bcac51647ab6906c13b217 /actionmailer/lib/action_mailer | |
parent | f32b974338cb965a27d521b32304aebd9811a9ba (diff) | |
download | rails-3b0e1d90938e3d4c98830e037b3da15b3f736f7f.tar.gz rails-3b0e1d90938e3d4c98830e037b3da15b3f736f7f.tar.bz2 rails-3b0e1d90938e3d4c98830e037b3da15b3f736f7f.zip |
Prefer string core_ext inflector methods over directly accessing Inflector.
Diffstat (limited to 'actionmailer/lib/action_mailer')
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 102 |
1 files changed, 51 insertions, 51 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index a3762bf81b..aafa26e79e 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -11,11 +11,11 @@ module ActionMailer #:nodoc: # = Mailer Models # # To use ActionMailer, you need to create a mailer model. - # + # # $ script/generate mailer Notifier # - # The generated model inherits from ActionMailer::Base. Emails are defined by creating methods within the model which are then - # used to set variables to be used in the mail template, to change options on the mail, or + # The generated model inherits from ActionMailer::Base. Emails are defined by creating methods within the model which are then + # used to set variables to be used in the mail template, to change options on the mail, or # to add attachments. # # Examples: @@ -48,7 +48,7 @@ module ActionMailer #:nodoc: # named after each key in the hash containing the value that that key points to. # # So, for example, <tt>body :account => recipient</tt> would result - # in an instance variable <tt>@account</tt> with the value of <tt>recipient</tt> being accessible in the + # in an instance variable <tt>@account</tt> with the value of <tt>recipient</tt> being accessible in the # view. # # @@ -57,7 +57,7 @@ module ActionMailer #:nodoc: # Like ActionController, each mailer class has a corresponding view directory # in which each method of the class looks for a template with its name. # 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 + # in your mailer model. For example, in the mailer defined above, the template at # <tt>app/views/notifier/signup_notification.erb</tt> would be used to generate the email. # # Variables defined in the model are accessible as instance variables in the view. @@ -71,48 +71,48 @@ module ActionMailer #:nodoc: # # You got a new note! # <%= truncate(note.body, 25) %> - # + # # # = Generating URLs - # + # # URLs can be generated in mailer views using <tt>url_for</tt> 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. + # 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 <tt>url_for</tt> you'll need to provide the <tt>:host</tt>, <tt>:controller</tt>, and <tt>:action</tt>: - # + # # <%= url_for(:host => "example.com", :controller => "welcome", :action => "greeting") %> # # When using named routes you only need to supply the <tt>:host</tt>: - # + # # <%= users_url(:host => "example.com") %> # # You will 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. # - # It is also possible to set a default host that will be used in all mailers by setting the <tt>:host</tt> option in + # It is also possible to set a default host that will be used in all mailers by setting the <tt>:host</tt> option in # the <tt>ActionMailer::Base.default_url_options</tt> hash as follows: # # ActionMailer::Base.default_url_options[:host] = "example.com" - # + # # This can also be set as a configuration option in <tt>config/environment.rb</tt>: # # config.action_mailer.default_url_options = { :host => "example.com" } # # If you do decide to set a default <tt>:host</tt> for your mailers you will 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 + # the <tt>url_for</tt> view helper will, by default, generate relative URLs when a <tt>:host</tt> option isn't # explicitly provided. # # = Sending mail # - # Once a mailer action and template are defined, you can deliver your message or create it and save it + # Once a mailer action and template are defined, you can deliver your message or create it and save it # for delivery later: # # Notifier.deliver_signup_notification(david) # sends the email # mail = Notifier.create_signup_notification(david) # => a tmail object # Notifier.deliver(mail) - # + # # You never instantiate your mailer class. Rather, your delivery instance # methods are automatically wrapped in class methods that start with the word # <tt>deliver_</tt> followed by the name of the mailer method that you would @@ -133,7 +133,7 @@ module ActionMailer #:nodoc: # from "system@example.com" # content_type "text/html" # Here's where the magic happens # end - # end + # end # # # = Multipart email @@ -155,17 +155,17 @@ module ActionMailer #:nodoc: # end # end # end - # + # # Multipart messages can also be used implicitly because ActionMailer 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. - # + # # For example, if the following templates existed: # * signup_notification.text.plain.erb # * signup_notification.text.html.erb # * signup_notification.text.xml.builder # * signup_notification.text.x-yaml.erb - # + # # Each would be rendered and added as a separate part to the message, # with the corresponding content type. The same body hash is passed to # each template. @@ -191,7 +191,7 @@ module ActionMailer #:nodoc: # a.body = generate_your_pdf_here() # end # end - # end + # end # # # = Configuration options @@ -209,7 +209,7 @@ module ActionMailer #:nodoc: # * <tt>:domain</tt> - If you need to specify a HELO domain, you can do it here. # * <tt>:user_name</tt> - If your mail server requires authentication, set the username in this setting. # * <tt>:password</tt> - If your mail server requires authentication, set the password in this setting. - # * <tt>:authentication</tt> - If your mail server requires authentication, you need to specify the authentication type here. + # * <tt>:authentication</tt> - If your mail server requires authentication, you need to specify the authentication type here. # This is a symbol and one of <tt>:plain</tt>, <tt>:login</tt>, <tt>:cram_md5</tt> # # * <tt>sendmail_settings</tt> - Allows you to override options for the <tt>:sendmail</tt> delivery method @@ -226,10 +226,10 @@ 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 + # * <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 <tt>@charset</tt>. # * <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 <tt>@content_type</tt>. + # can also pick a different content type from inside a method with <tt>@content_type</tt>. # * <tt>default_mime_version</tt> - The default mime version used for the message. Defaults to "1.0". You # can also pick a different value from inside a method with <tt>@mime_version</tt>. # * <tt>default_implicit_parts_order</tt> - When a message is built implicitly (i.e. multiple parts are assembled from templates @@ -249,16 +249,16 @@ module ActionMailer #:nodoc: cattr_accessor :template_extensions @@template_extensions = ['erb', 'builder', 'rhtml', 'rxml'] - @@smtp_settings = { - :address => "localhost", - :port => 25, - :domain => 'localhost.localdomain', - :user_name => nil, - :password => nil, + @@smtp_settings = { + :address => "localhost", + :port => 25, + :domain => 'localhost.localdomain', + :user_name => nil, + :password => nil, :authentication => nil } cattr_accessor :smtp_settings - + @@sendmail_settings = { :location => '/usr/sbin/sendmail', :arguments => '-i -t' @@ -270,10 +270,10 @@ module ActionMailer #:nodoc: superclass_delegating_accessor :delivery_method self.delivery_method = :smtp - + @@perform_deliveries = true cattr_accessor :perform_deliveries - + @@deliveries = [] cattr_accessor :deliveries @@ -282,7 +282,7 @@ module ActionMailer #:nodoc: @@default_content_type = "text/plain" cattr_accessor :default_content_type - + @@default_mime_version = "1.0" cattr_accessor :default_mime_version @@ -291,47 +291,47 @@ module ActionMailer #:nodoc: # Specify the BCC addresses for the message adv_attr_accessor :bcc - + # Define the body of the message. This is either a Hash (in which case it # specifies the variables to pass to the template when it is rendered), # or a string, in which case it specifies the actual text of the message. adv_attr_accessor :body - + # Specify the CC addresses for the message. adv_attr_accessor :cc - + # Specify the charset to use for the message. This defaults to the # +default_charset+ specified for ActionMailer::Base. adv_attr_accessor :charset - + # Specify the content type for the message. This defaults to <tt>text/plain</tt> # in most cases, but can be automatically set in some situations. adv_attr_accessor :content_type - + # Specify the from address for the message. adv_attr_accessor :from - + # Specify additional headers to be added to the message. adv_attr_accessor :headers - + # Specify the order in which parts should be sorted, based on content-type. # This defaults to the value for the +default_implicit_parts_order+. adv_attr_accessor :implicit_parts_order - + # Defaults to "1.0", but may be explicitly given if needed. adv_attr_accessor :mime_version - + # The recipient addresses for the message, either as a string (for a single # address) or an array (for multiple addresses). adv_attr_accessor :recipients - + # The date on which the message was sent. If not set (the default), the # header will be set by the delivery agent. adv_attr_accessor :sent_on - + # Specify the subject of the message. adv_attr_accessor :subject - + # Specify the template name to use for current message. This is the "base" # template name, without the extension or directory, and may be used to # have multiple mailer methods share the same template. @@ -347,7 +347,7 @@ module ActionMailer #:nodoc: self.class.mailer_name end end - + def mailer_name=(value) self.class.mailer_name = value end @@ -425,7 +425,7 @@ module ActionMailer #:nodoc: # remain uninitialized (useful when you only need to invoke the "receive" # method, for instance). def initialize(method_name=nil, *parameters) #:nodoc: - create!(method_name, *parameters) if method_name + create!(method_name, *parameters) if method_name end # Initialize the mailer via the given +method_name+. The body will be @@ -511,7 +511,7 @@ module ActionMailer #:nodoc: @content_type ||= @@default_content_type.dup @implicit_parts_order ||= @@default_implicit_parts_order.dup @template ||= method_name - @mailer_name ||= Inflector.underscore(self.class.name) + @mailer_name ||= self.class.name.underscore @parts ||= [] @headers ||= {} @body ||= {} @@ -597,7 +597,7 @@ module ActionMailer #:nodoc: part = (TMail::Mail === p ? p : p.to_mail(self)) m.parts << part end - + if real_content_type =~ /multipart/ ctype_attrs.delete "charset" m.set_content_type(real_content_type, nil, ctype_attrs) @@ -612,7 +612,7 @@ module ActionMailer #:nodoc: mail.ready_to_send sender = mail['return-path'] || mail.from - Net::SMTP.start(smtp_settings[:address], smtp_settings[:port], smtp_settings[:domain], + Net::SMTP.start(smtp_settings[:address], smtp_settings[:port], smtp_settings[:domain], smtp_settings[:user_name], smtp_settings[:password], smtp_settings[:authentication]) do |smtp| smtp.sendmail(mail.encoded, sender, destinations) end |