From 732c724df61bc8b780dc42817625b25a321908e4 Mon Sep 17 00:00:00 2001 From: Grant Hollingworth Date: Wed, 5 Nov 2008 22:54:37 -0500 Subject: Turn on STARTTLS if it is available in Net::SMTP (added in Ruby 1.8.7) and the SMTP server supports it [#1336 state:committed] Signed-off-by: David Heinemeier Hansson --- actionmailer/lib/action_mailer/base.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'actionmailer/lib') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 043f56ba17..d63a608109 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -663,8 +663,10 @@ 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], - smtp_settings[:user_name], smtp_settings[:password], smtp_settings[:authentication]) do |smtp| + smtp = Net::SMTP.new(smtp_settings[:address], smtp_settings[:port]) + smtp.enable_starttls_auto if smtp.respond_to?(:enable_starttls_auto) + smtp.start(smtp_settings[:domain], smtp_settings[:user_name], smtp_settings[:password], + smtp_settings[:authentication]) do |smtp| smtp.sendmail(mail.encoded, sender, destinations) end end -- cgit v1.2.3 From a62e9e90d8f47a643c9355f782ab4891fa8fefaa Mon Sep 17 00:00:00 2001 From: Joel Chippindale Date: Tue, 11 Nov 2008 09:39:50 -0600 Subject: Fix for ActionMailer::Base.method_missing so that it raises NoMethodError when no method is found [#1330 state:resolved] Signed-off-by: Joshua Peek --- actionmailer/lib/action_mailer/base.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'actionmailer/lib') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index d63a608109..17b5eaa8d1 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -386,12 +386,14 @@ module ActionMailer #:nodoc: end def method_missing(method_symbol, *parameters) #:nodoc: - match = matches_dynamic_method?(method_symbol) - case match[1] - when 'create' then new(match[2], *parameters).mail - when 'deliver' then new(match[2], *parameters).deliver! - when 'new' then nil - else super + if match = matches_dynamic_method?(method_symbol) + case match[1] + when 'create' then new(match[2], *parameters).mail + when 'deliver' then new(match[2], *parameters).deliver! + when 'new' then nil + end + else + super end end -- cgit v1.2.3 From c65075feb6c4ce15582bc08411e6698d782249a7 Mon Sep 17 00:00:00 2001 From: Joel Chippindale Date: Tue, 11 Nov 2008 09:45:53 -0600 Subject: Fixed method_missing for ActionMailer so it no longer matches methods where deliver or create are not a suffix [#1318 state:resolved] Signed-off-by: Joshua Peek --- actionmailer/lib/action_mailer/base.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'actionmailer/lib') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 17b5eaa8d1..19ce77ea5a 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -391,6 +391,7 @@ module ActionMailer #:nodoc: when 'create' then new(match[2], *parameters).mail when 'deliver' then new(match[2], *parameters).deliver! when 'new' then nil + else super end else super @@ -442,7 +443,7 @@ module ActionMailer #:nodoc: private def matches_dynamic_method?(method_name) #:nodoc: method_name = method_name.to_s - /(create|deliver)_([_a-z]\w*)/.match(method_name) || /^(new)$/.match(method_name) + /^(create|deliver)_([_a-z]\w*)/.match(method_name) || /^(new)$/.match(method_name) end end -- cgit v1.2.3 From 61e43700b85de753b6254893d5365e04d3465b9a Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Fri, 14 Nov 2008 12:26:50 +0100 Subject: Prepare for RC2 --- actionmailer/lib/action_mailer/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionmailer/lib') diff --git a/actionmailer/lib/action_mailer/version.rb b/actionmailer/lib/action_mailer/version.rb index 9728d1b4db..7ba13c7df8 100644 --- a/actionmailer/lib/action_mailer/version.rb +++ b/actionmailer/lib/action_mailer/version.rb @@ -2,7 +2,7 @@ module ActionMailer module VERSION #:nodoc: MAJOR = 2 MINOR = 2 - TINY = 0 + TINY = 1 STRING = [MAJOR, MINOR, TINY].join('.') end -- cgit v1.2.3 From 1d8c4cf6e0b115bac598f7d817ee98dc298580ff Mon Sep 17 00:00:00 2001 From: Mike Gunderloy Date: Sun, 16 Nov 2008 20:44:30 -0600 Subject: Fix markup for cattr_accessors in Action View and Action Mailer to work better with RDoc 2+. --- actionmailer/lib/action_mailer/base.rb | 111 ++++++++++++++++++++------------- 1 file changed, 68 insertions(+), 43 deletions(-) (limited to 'actionmailer/lib') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 19ce77ea5a..c4470810dc 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -201,49 +201,7 @@ module ActionMailer #:nodoc: # end # # - # = Configuration options - # - # These options are specified on the class level, like ActionMailer::Base.template_root = "/my/templates" - # - # * template_root - Determines the base from which template references will be made. - # - # * logger - 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. - # - # * 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. - # * :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. - # This is a symbol and one of :plain, :login, :cram_md5. - # - # * 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. - # - # * 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, and :test. - # - # * perform_deliveries - Determines whether deliver_* methods are actually carried out. By default they are, - # but this can be turned off to help 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 - 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+. - # * default_content_type - 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+. - # * default_mime_version - The default mime version used for the message. Defaults to 1.0. You - # can also pick a different value from inside a method with +mime_version+. - # * default_implicit_parts_order - 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 - # ["text/html", "text/enriched", "text/plain"]. 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+. + # Configuration options are specified on the class level, like ActionMailer::Base.template_root = "/my/templates" class Base include AdvAttrAccessor, PartContainer if Object.const_defined?(:ActionController) @@ -254,6 +212,10 @@ module ActionMailer #:nodoc: private_class_method :new #:nodoc: class_inheritable_accessor :view_paths + ## + # :singleton-method: + # 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. cattr_accessor :logger @@smtp_settings = { @@ -264,88 +226,150 @@ module ActionMailer #:nodoc: :password => nil, :authentication => nil } + ## + # :singleton-method: + # Allows detailed configuration for :smtp delivery method: + # * :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. + # This is a symbol and one of :plain, :login, :cram_md5. cattr_accessor :smtp_settings @@sendmail_settings = { :location => '/usr/sbin/sendmail', :arguments => '-i -t' } + ## + # :singleton-method: + # 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. cattr_accessor :sendmail_settings @@raise_delivery_errors = true + ## + # :singleton-method: + # Whether or not errors should be raised if the email fails to be delivered. cattr_accessor :raise_delivery_errors + ## + # :singleton-method: + # Defines a delivery method. Possible values are :smtp (default), :sendmail, and :test. superclass_delegating_accessor :delivery_method self.delivery_method = :smtp @@perform_deliveries = true + ## + # :singleton-method: + # Determines whether deliver_* methods are actually carried out. By default they are, + # but this can be turned off to help functional testing. cattr_accessor :perform_deliveries @@deliveries = [] + ## + # :singleton-method: + # Keeps an array of all the emails sent out through the Action Mailer with delivery_method :test. Most useful + # for unit and functional testing. cattr_accessor :deliveries @@default_charset = "utf-8" + ## + # :singleton-method: + # 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+. cattr_accessor :default_charset @@default_content_type = "text/plain" + ## + # :singleton-method: + # 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+. cattr_accessor :default_content_type @@default_mime_version = "1.0" + ## + # :singleton-method: + # The default mime version used for the message. Defaults to 1.0. You + # can also pick a different value from inside a method with +mime_version+. cattr_accessor :default_mime_version @@default_implicit_parts_order = [ "text/html", "text/enriched", "text/plain" ] + ## + # :singleton-method: + # 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 + # ["text/html", "text/enriched", "text/plain"]. 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+. cattr_accessor :default_implicit_parts_order cattr_reader :protected_instance_variables @@protected_instance_variables = %w(@body) + ## # 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 text/plain # 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 the address (if different than the "from" address) to direct # replies to this message. adv_attr_accessor :reply_to + ## # 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. @@ -432,6 +456,7 @@ module ActionMailer #:nodoc: "Use ActionView::Base.register_template_extension instead", caller) end + # Determines the base from which template references will be made. def template_root self.view_paths && self.view_paths.first end -- cgit v1.2.3