From 0612fd0f09977dece11a0325a0d7ee07c5cab35c Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Fri, 7 Aug 2009 03:18:45 -0300 Subject: Replace _render_template_with_layout with _render_template since the layout is optional --- actionmailer/lib/action_mailer/base.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actionmailer/lib') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index b5a0d0ab96..7b03a7f9ff 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -566,7 +566,7 @@ module ActionMailer #:nodoc: @template = initialize_template_class(body) layout = _pick_layout(layout, true) unless ActionController::Base.exempt_from_layout.include?(template.handler) - @template._render_template_with_layout(template, layout, {}) + @template._render_template(template, layout, {}) ensure @current_template_content_type = nil end @@ -592,7 +592,7 @@ module ActionMailer #:nodoc: !template || ActionController::Base.exempt_from_layout.include?(template.handler)) if template - @template._render_template_with_layout(template, layout, opts) + @template._render_template(template, layout, opts) elsif inline = opts[:inline] @template._render_inline(inline, layout, opts) end -- cgit v1.2.3 From 010a0c92eb573cd4c216c51371356adddfde11cf Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Fri, 7 Aug 2009 15:00:12 -0300 Subject: Rename find_by_parts and find_by_parts? to find and exists? --- actionmailer/lib/action_mailer/base.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actionmailer/lib') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 7b03a7f9ff..e36ee72298 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -499,7 +499,7 @@ module ActionMailer #:nodoc: # ==== # TODO: Revisit this # template_exists = @parts.empty? - # template_exists ||= template_root.find_by_parts("#{mailer_name}/#{@template}") + # template_exists ||= template_root.find("#{mailer_name}/#{@template}") # @body = render_message(@template, @body) if template_exists # Finally, if there are other message parts and a textual body exists, @@ -585,7 +585,7 @@ module ActionMailer #:nodoc: if file prefix = mailer_name unless file =~ /\// - template = view_paths.find_by_parts(file, {:formats => formats}, prefix) + template = view_paths.find(file, {:formats => formats}, prefix) end layout = _pick_layout(layout, -- cgit v1.2.3 From 5fdc33c1a37b4c321135753ed546e8afc2dbaf3e Mon Sep 17 00:00:00 2001 From: Matt Duncan Date: Fri, 7 Aug 2009 21:37:21 -0400 Subject: Default sent_on time to now in ActionMailer Signed-off-by: Michael Koziarski [#2607 state:committed] --- actionmailer/lib/action_mailer/base.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'actionmailer/lib') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index e36ee72298..d01f561f50 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -556,6 +556,7 @@ module ActionMailer #:nodoc: @headers ||= {} @body ||= {} @mime_version = @@default_mime_version.dup if @@default_mime_version + @sent_on ||= Time.now end def render_template(template, body) -- cgit v1.2.3 From fbe6c3c19553fd05edc904af62fbfc8aee1d907d Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Fri, 7 Aug 2009 20:56:54 -0700 Subject: Adds a :file delivery_method to save email to a file on disk Signed-off-by: Michael Koziarski [#2438 state:committed] --- actionmailer/lib/action_mailer/base.rb | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'actionmailer/lib') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index d01f561f50..5ecefe7c09 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -1,3 +1,5 @@ +require 'tmpdir' + require "active_support/core_ext/class" # Use the old layouts until actionmailer gets refactored require "action_controller/legacy/layout" @@ -224,9 +226,13 @@ module ActionMailer #:nodoc: # * :location - The location of the sendmail executable. Defaults to /usr/sbin/sendmail. # * :arguments - The command line arguments. Defaults to -i -t. # + # * 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. + # # * 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. + # * delivery_method - Defines a delivery method. Possible values are :smtp (default), :sendmail, :test, + # and :file. # # * perform_deliveries - Determines whether deliver_* methods are actually carried out. By default they are, # but this can be turned off to help functional testing. @@ -279,6 +285,12 @@ module ActionMailer #:nodoc: } cattr_accessor :sendmail_settings + @@file_settings = { + :location => defined?(Rails) ? "#{Rails.root}/tmp/mails" : "#{Dir.tmpdir}/mails" + } + + cattr_accessor :file_settings + @@raise_delivery_errors = true cattr_accessor :raise_delivery_errors @@ -724,6 +736,14 @@ module ActionMailer #:nodoc: def perform_delivery_test(mail) deliveries << mail end + + def perform_delivery_file(mail) + FileUtils.mkdir_p file_settings[:location] + + (mail.to + mail.cc + mail.bcc).uniq.each do |to| + File.open(File.join(file_settings[:location], to), 'a') { |f| f.write(mail) } + end + end end Base.class_eval do -- cgit v1.2.3