diff options
author | José Valim and Mikel Lindsaar <pair@programming.com> | 2010-01-25 00:37:12 +0100 |
---|---|---|
committer | José Valim and Mikel Lindsaar <pair@programming.com> | 2010-01-25 00:37:12 +0100 |
commit | e1c131863897390d04bd5515765236590747f2c1 (patch) | |
tree | a1bbe3b869ed48c16b7c259812e3d459e2188734 /actionmailer/lib/action_mailer | |
parent | 48faf53be19c569e85f43a4dbfa63fe81618b09f (diff) | |
download | rails-e1c131863897390d04bd5515765236590747f2c1.tar.gz rails-e1c131863897390d04bd5515765236590747f2c1.tar.bz2 rails-e1c131863897390d04bd5515765236590747f2c1.zip |
Added delivers_from.
Diffstat (limited to 'actionmailer/lib/action_mailer')
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 84d50fa1f4..552fd7ccb8 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -273,6 +273,9 @@ module ActionMailer #:nodoc: private_class_method :new #:nodoc: + extlib_inheritable_accessor :default_from + self.default_from = nil + extlib_inheritable_accessor :default_charset self.default_charset = "utf-8" @@ -298,6 +301,12 @@ module ActionMailer #:nodoc: attr_writer :mailer_name alias :controller_path :mailer_name + # Sets who is the default sender for the e-mail + def delivers_from(value = nil) + self.default_from = value if value + self.default_from + end + # Receives a raw email, parses it into an email object, decodes it, # 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 @@ -318,7 +327,7 @@ module ActionMailer #:nodoc: end # TODO The delivery should happen inside the instrument block - def delivered_email(mail) + def delivered_email(mail) #:nodoc: ActiveSupport::Notifications.instrument("action_mailer.deliver") do |payload| self.set_payload_for_mail(payload, mail) end @@ -387,8 +396,9 @@ module ActionMailer #:nodoc: charset = headers[:charset] || m.charset || self.class.default_charset.dup mime_version = headers[:mime_version] || m.mime_version || self.class.default_mime_version.dup - # Set subjects and fields quotings + # Set fields quotings headers[:subject] ||= default_subject + headers[:from] ||= self.class.default_from.dup quote_fields!(headers, charset) # Render the templates and blocks |