actionmailer 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of actionmailer might be problematic. Click here for more details.
- data/CHANGELOG +13 -0
- data/lib/action_mailer/base.rb +50 -31
- data/rakefile +3 -3
- metadata +2 -2
data/CHANGELOG
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
*0.5*
|
2
|
+
|
3
|
+
* Added access to custom headers, like cc, bcc, and reply-to #268 [Andreas Schwarz]. Example:
|
4
|
+
|
5
|
+
def post_notification(recipients, post)
|
6
|
+
@recipients = recipients
|
7
|
+
@from = post.author.email_address_with_name
|
8
|
+
@headers["bcc"] = SYSTEM_ADMINISTRATOR_EMAIL
|
9
|
+
@headers["reply-to"] = "notifications@example.com"
|
10
|
+
@subject = "[#{post.account.name} #{post.title}]"
|
11
|
+
@body["post"] = post
|
12
|
+
end
|
13
|
+
|
1
14
|
*0.4* (5)
|
2
15
|
|
3
16
|
* Consolidated the server configuration options into Base#server_settings= and expanded that with controls for authentication and more [Marten]
|
data/lib/action_mailer/base.rb
CHANGED
@@ -3,10 +3,12 @@ module ActionMailer #:nodoc:
|
|
3
3
|
#
|
4
4
|
# class ApplicationMailer < ActionMailer::Base
|
5
5
|
# def post_notification(recipients, post)
|
6
|
-
# @recipients
|
7
|
-
# @
|
8
|
-
# @
|
9
|
-
# @
|
6
|
+
# @recipients = recipients
|
7
|
+
# @from = post.author.email_address_with_name
|
8
|
+
# @headers["bcc"] = SYSTEM_ADMINISTRATOR_EMAIL
|
9
|
+
# @headers["reply-to"] = "notifications@example.com"
|
10
|
+
# @subject = "[#{post.account.name} #{post.title}]"
|
11
|
+
# @body["post"] = post
|
10
12
|
# end
|
11
13
|
#
|
12
14
|
# def comment_notification(recipient, comment)
|
@@ -24,24 +26,41 @@ module ActionMailer #:nodoc:
|
|
24
26
|
#
|
25
27
|
# ApplicationMailer.create_comment_notification(david, hello_world) # => a tmail object
|
26
28
|
# ApplicationMailer.deliver_comment_notification(david, hello_world) # sends the email
|
29
|
+
#
|
30
|
+
# = Configuration options
|
31
|
+
#
|
32
|
+
# These options are specified on the class level, like <tt>ActionMailer::Base.template_root = "/my/templates"</tt>
|
33
|
+
#
|
34
|
+
# * <tt>template_root</tt> - template root determines the base from which template references will be made.
|
35
|
+
#
|
36
|
+
# * <tt>logger</tt> - the logger is used for generating information on the mailing run if available.
|
37
|
+
# Can be set to nil for no logging. Compatible with both Ruby's own Logger and Log4r loggers.
|
38
|
+
#
|
39
|
+
# * <tt>server_settings</tt> - Allows detailed configuration of the server:
|
40
|
+
# * <tt>:address</tt> Allows you to use a remote mail server. Just change it away from it's default "localhost" setting.
|
41
|
+
# * <tt>:port</tt> On the off change that your mail server doesn't run on port 25, you can change it.
|
42
|
+
# * <tt>:domain</tt> If you need to specify a HELO domain, you can do it here.
|
43
|
+
# * <tt>:user_name</tt> If your mail server requires authentication, set the username and password in these two settings.
|
44
|
+
# * <tt>:password</tt> If your mail server requires authentication, set the username and password in these two settings.
|
45
|
+
# * <tt>:authentication</tt> If your mail server requires authentication, you need to specify the authentication type here.
|
46
|
+
# This is a symbol and one of :plain, :login, :cram_md5
|
47
|
+
#
|
48
|
+
# * <tt>raise_delivery_errors</tt> - whether or not errors should be raised if the email fails to be delivered.
|
49
|
+
#
|
50
|
+
# * <tt>delivery_method</tt> - Defines a delivery method. Possible values are :smtp (default), :sendmail, and :test.
|
51
|
+
# Sendmail is assumed to be present at "/usr/sbin/sendmail".
|
52
|
+
#
|
53
|
+
# * <tt>perform_deliveries</tt> - Determines whether deliver_* methods are actually carried out. By default they are,
|
54
|
+
# but this can be turned off to help functional testing.
|
55
|
+
#
|
56
|
+
# * <tt>deliveries</tt> - Keeps an array of all the emails sent out through the Action Mailer with delivery_method :test. Most useful
|
57
|
+
# for unit and functional testing.
|
27
58
|
class Base
|
28
|
-
private_class_method :new
|
59
|
+
private_class_method :new #:nodoc:
|
29
60
|
|
30
|
-
# Template root determines the base from which template references will be made.
|
31
61
|
cattr_accessor :template_root
|
32
|
-
|
33
|
-
# The logger is used for generating information on the mailing run if available.
|
34
|
-
# Can be set to nil for no logging. Compatible with both Ruby's own Logger and Log4r loggers.
|
35
62
|
cattr_accessor :logger
|
36
63
|
|
37
|
-
# Allows detailed configuration of the server:
|
38
|
-
# * <tt>:address</tt> Allows you to use a remote mail server. Just change it away from it's default "localhost" setting.
|
39
|
-
# * <tt>:port</tt> On the off change that your mail server doesn't run on port 25, you can change it.
|
40
|
-
# * <tt>:domain</tt> If you need to specify a HELO domain, you can do it here.
|
41
|
-
# * <tt>:user_name</tt> If your mail server requires authentication, set the username and password in these two settings.
|
42
|
-
# * <tt>:password</tt> If your mail server requires authentication, set the username and password in these two settings.
|
43
|
-
# * <tt>:authentication</tt> If your mail server requires authentication, you need to specify the authentication type here.
|
44
|
-
# This is a symbol and one of :plain, :login, :cram_md5
|
45
64
|
@@server_settings = {
|
46
65
|
:address => "localhost",
|
47
66
|
:port => 25,
|
@@ -52,27 +71,23 @@ module ActionMailer #:nodoc:
|
|
52
71
|
}
|
53
72
|
cattr_accessor :server_settings
|
54
73
|
|
55
|
-
|
56
|
-
# Whether or not errors should be raised if the email fails to be delivered
|
57
74
|
@@raise_delivery_errors = true
|
58
75
|
cattr_accessor :raise_delivery_errors
|
59
76
|
|
60
|
-
# Defines a delivery method. Possible values are :smtp (default), :sendmail, and :test.
|
61
|
-
# Sendmail is assumed to be present at "/usr/sbin/sendmail".
|
62
77
|
@@delivery_method = :smtp
|
63
78
|
cattr_accessor :delivery_method
|
64
79
|
|
65
|
-
# Determines whether deliver_* methods are actually carried out. By default they are,
|
66
|
-
# but this can be turned off to help functional testing.
|
67
80
|
@@perform_deliveries = true
|
68
81
|
cattr_accessor :perform_deliveries
|
69
82
|
|
70
|
-
# Keeps an array of all the emails sent out through the Action Mailer with delivery_method :test. Most useful
|
71
|
-
# for unit and functional testing.
|
72
83
|
@@deliveries = []
|
73
84
|
cattr_accessor :deliveries
|
74
85
|
|
75
|
-
attr_accessor :recipients, :subject, :body, :from, :sent_on, :bcc, :cc
|
86
|
+
attr_accessor :recipients, :subject, :body, :from, :sent_on, :headers, :bcc, :cc
|
87
|
+
|
88
|
+
def initialize
|
89
|
+
@headers = {}
|
90
|
+
end
|
76
91
|
|
77
92
|
class << self
|
78
93
|
def method_missing(method_symbol, *parameters)#:nodoc:
|
@@ -88,14 +103,18 @@ module ActionMailer #:nodoc:
|
|
88
103
|
end
|
89
104
|
end
|
90
105
|
|
91
|
-
def mail(to, subject, body, from, timestamp = nil) #:nodoc:
|
92
|
-
deliver(create(to, subject, body, from, timestamp))
|
106
|
+
def mail(to, subject, body, from, timestamp = nil, headers = nil) #:nodoc:
|
107
|
+
deliver(create(to, subject, body, from, timestamp, headers))
|
93
108
|
end
|
94
109
|
|
95
|
-
def create(to, subject, body, from, timestamp = nil) #:nodoc:
|
110
|
+
def create(to, subject, body, from, timestamp = nil, headers = nil) #:nodoc:
|
96
111
|
m = TMail::Mail.new
|
97
112
|
m.to, m.subject, m.body, m.from = to, subject, body, from
|
98
113
|
m.date = timestamp.respond_to?("to_time") ? timestamp.to_time : (timestamp || Time.now)
|
114
|
+
headers.each do |k, v|
|
115
|
+
m[k] = v
|
116
|
+
end
|
117
|
+
|
99
118
|
return m
|
100
119
|
end
|
101
120
|
|
@@ -129,9 +148,9 @@ module ActionMailer #:nodoc:
|
|
129
148
|
mailer.send(method_name, *parameters)
|
130
149
|
|
131
150
|
if String === mailer.body
|
132
|
-
mail = create(mailer.recipients, mailer.subject, mailer.body, mailer.from, mailer.sent_on)
|
151
|
+
mail = create(mailer.recipients, mailer.subject, mailer.body, mailer.from, mailer.sent_on, mailer.headers)
|
133
152
|
else
|
134
|
-
mail = create(mailer.recipients, mailer.subject, render_body(mailer, method_name), mailer.from, mailer.sent_on)
|
153
|
+
mail = create(mailer.recipients, mailer.subject, render_body(mailer, method_name), mailer.from, mailer.sent_on, mailer.headers)
|
135
154
|
end
|
136
155
|
|
137
156
|
mail.bcc = @bcc if @bcc
|
data/rakefile
CHANGED
@@ -8,7 +8,7 @@ require 'rake/contrib/rubyforgepublisher'
|
|
8
8
|
|
9
9
|
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
|
10
10
|
PKG_NAME = 'actionmailer'
|
11
|
-
PKG_VERSION = '0.
|
11
|
+
PKG_VERSION = '0.5.0' + PKG_BUILD
|
12
12
|
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
13
13
|
|
14
14
|
desc "Default Task"
|
@@ -58,8 +58,8 @@ spec = Gem::Specification.new do |s|
|
|
58
58
|
s.autorequire = 'action_mailer'
|
59
59
|
|
60
60
|
s.files = [ "rakefile", "install.rb", "README", "CHANGELOG", "MIT-LICENSE" ]
|
61
|
-
s.files = s.files + Dir.glob( "lib/**/*" ).delete_if { |item| item.include?( "
|
62
|
-
s.files = s.files + Dir.glob( "test/**/*" ).delete_if { |item| item.include?( "
|
61
|
+
s.files = s.files + Dir.glob( "lib/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
|
62
|
+
s.files = s.files + Dir.glob( "test/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
|
63
63
|
end
|
64
64
|
|
65
65
|
Rake::GemPackageTask.new(spec) do |p|
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.1
|
|
3
3
|
specification_version: 1
|
4
4
|
name: actionmailer
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2004-
|
6
|
+
version: 0.5.0
|
7
|
+
date: 2004-12-16
|
8
8
|
summary: Service layer for easy email delivery and testing.
|
9
9
|
require_paths:
|
10
10
|
- lib
|