aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/lib/action_mailer
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2004-12-07 09:10:50 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2004-12-07 09:10:50 +0000
commit165097ede50e609ff5661b969b95cc9959722ce1 (patch)
tree2349f84f19fb0ed2f18dfe71ec457f989773fbb3 /actionmailer/lib/action_mailer
parent35c89c4176c12353cd772c61e1d2dc5202b4d44f (diff)
downloadrails-165097ede50e609ff5661b969b95cc9959722ce1.tar.gz
rails-165097ede50e609ff5661b969b95cc9959722ce1.tar.bz2
rails-165097ede50e609ff5661b969b95cc9959722ce1.zip
Added access to custom headers, like cc, bcc, and reply-to #268 [Andreas Schwarz]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@54 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionmailer/lib/action_mailer')
-rw-r--r--actionmailer/lib/action_mailer/base.rb30
1 files changed, 20 insertions, 10 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb
index 389499c8fa..5ca463ddf8 100644
--- a/actionmailer/lib/action_mailer/base.rb
+++ b/actionmailer/lib/action_mailer/base.rb
@@ -3,10 +3,12 @@ module ActionMailer #:nodoc:
#
# class ApplicationMailer < ActionMailer::Base
# def post_notification(recipients, post)
- # @recipients = recipients
- # @subject = "[#{post.account.name} #{post.title}]"
- # @body["post"] = post
- # @from = post.author.email_address_with_name
+ # @recipients = recipients
+ # @from = post.author.email_address_with_name
+ # @headers["bcc"] = SYSTEM_ADMINISTRATOR_EMAIL
+ # @headers["reply-to"] = "notifications@example.com"
+ # @subject = "[#{post.account.name} #{post.title}]"
+ # @body["post"] = post
# end
#
# def comment_notification(recipient, comment)
@@ -72,7 +74,11 @@ module ActionMailer #:nodoc:
@@deliveries = []
cattr_accessor :deliveries
- attr_accessor :recipients, :subject, :body, :from, :sent_on, :bcc, :cc
+ attr_accessor :recipients, :subject, :body, :from, :sent_on, :headers, :bcc, :cc
+
+ def initialize
+ @headers = {}
+ end
class << self
def method_missing(method_symbol, *parameters)#:nodoc:
@@ -88,14 +94,18 @@ module ActionMailer #:nodoc:
end
end
- def mail(to, subject, body, from, timestamp = nil) #:nodoc:
- deliver(create(to, subject, body, from, timestamp))
+ def mail(to, subject, body, from, timestamp = nil, headers = nil) #:nodoc:
+ deliver(create(to, subject, body, from, timestamp, headers))
end
- def create(to, subject, body, from, timestamp = nil) #:nodoc:
+ def create(to, subject, body, from, timestamp = nil, headers = nil) #:nodoc:
m = TMail::Mail.new
m.to, m.subject, m.body, m.from = to, subject, body, from
m.date = timestamp.respond_to?("to_time") ? timestamp.to_time : (timestamp || Time.now)
+ headers.each do |k, v|
+ m[k] = v
+ end
+
return m
end
@@ -129,9 +139,9 @@ module ActionMailer #:nodoc:
mailer.send(method_name, *parameters)
if String === mailer.body
- mail = create(mailer.recipients, mailer.subject, mailer.body, mailer.from, mailer.sent_on)
+ mail = create(mailer.recipients, mailer.subject, mailer.body, mailer.from, mailer.sent_on, mailer.headers)
else
- mail = create(mailer.recipients, mailer.subject, render_body(mailer, method_name), mailer.from, mailer.sent_on)
+ mail = create(mailer.recipients, mailer.subject, render_body(mailer, method_name), mailer.from, mailer.sent_on, mailer.headers)
end
mail.bcc = @bcc if @bcc