actionmailer 3.0.4 → 7.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +219 -0
- data/MIT-LICENSE +1 -1
- data/README.rdoc +49 -55
- data/lib/action_mailer/base.rb +688 -387
- data/lib/action_mailer/callbacks.rb +31 -0
- data/lib/action_mailer/collector.rb +11 -9
- data/lib/action_mailer/delivery_methods.rb +35 -37
- data/lib/action_mailer/deprecator.rb +7 -0
- data/lib/action_mailer/form_builder.rb +37 -0
- data/lib/action_mailer/gem_version.rb +17 -0
- data/lib/action_mailer/inline_preview_interceptor.rb +59 -0
- data/lib/action_mailer/log_subscriber.rb +30 -8
- data/lib/action_mailer/mail_delivery_job.rb +48 -0
- data/lib/action_mailer/mail_helper.rb +59 -18
- data/lib/action_mailer/message_delivery.rb +156 -0
- data/lib/action_mailer/parameterized.rb +156 -0
- data/lib/action_mailer/preview.rb +166 -0
- data/lib/action_mailer/queued_delivery.rb +12 -0
- data/lib/action_mailer/railtie.rb +75 -7
- data/lib/action_mailer/rescuable.rb +33 -0
- data/lib/action_mailer/test_case.rb +75 -25
- data/lib/action_mailer/test_helper.rb +238 -15
- data/lib/action_mailer/version.rb +8 -7
- data/lib/action_mailer.rb +45 -18
- data/lib/rails/generators/mailer/USAGE +13 -8
- data/lib/rails/generators/mailer/mailer_generator.rb +26 -4
- data/lib/rails/generators/mailer/templates/application_mailer.rb.tt +6 -0
- data/lib/rails/generators/mailer/templates/mailer.rb.tt +17 -0
- metadata +175 -87
- data/CHANGELOG +0 -424
- data/lib/action_mailer/adv_attr_accessor.rb +0 -26
- data/lib/action_mailer/deprecated_api.rb +0 -147
- data/lib/action_mailer/old_api.rb +0 -259
- data/lib/action_mailer/tmail_compat.rb +0 -34
- data/lib/rails/generators/mailer/templates/mailer.rb +0 -16
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
require 'active_support/concern'
|
|
2
|
-
require 'active_support/core_ext/object/try'
|
|
3
|
-
require 'active_support/core_ext/object/blank'
|
|
4
|
-
|
|
5
|
-
module ActionMailer
|
|
6
|
-
module OldApi #:nodoc:
|
|
7
|
-
extend ActiveSupport::Concern
|
|
8
|
-
|
|
9
|
-
included do
|
|
10
|
-
extend ActionMailer::AdvAttrAccessor
|
|
11
|
-
|
|
12
|
-
@@protected_instance_variables = %w(@parts)
|
|
13
|
-
cattr_reader :protected_instance_variables
|
|
14
|
-
|
|
15
|
-
# Specify the BCC addresses for the message
|
|
16
|
-
adv_attr_accessor :bcc
|
|
17
|
-
|
|
18
|
-
# Specify the CC addresses for the message.
|
|
19
|
-
adv_attr_accessor :cc
|
|
20
|
-
|
|
21
|
-
# Specify the charset to use for the message. This defaults to the
|
|
22
|
-
# +default_charset+ specified for ActionMailer::Base.
|
|
23
|
-
adv_attr_accessor :charset
|
|
24
|
-
|
|
25
|
-
# Specify the content type for the message. This defaults to <tt>text/plain</tt>
|
|
26
|
-
# in most cases, but can be automatically set in some situations.
|
|
27
|
-
adv_attr_accessor :content_type
|
|
28
|
-
|
|
29
|
-
# Specify the from address for the message.
|
|
30
|
-
adv_attr_accessor :from
|
|
31
|
-
|
|
32
|
-
# Specify the address (if different than the "from" address) to direct
|
|
33
|
-
# replies to this message.
|
|
34
|
-
adv_attr_accessor :reply_to
|
|
35
|
-
|
|
36
|
-
# Specify the order in which parts should be sorted, based on content-type.
|
|
37
|
-
# This defaults to the value for the +default_implicit_parts_order+.
|
|
38
|
-
adv_attr_accessor :implicit_parts_order
|
|
39
|
-
|
|
40
|
-
# Defaults to "1.0", but may be explicitly given if needed.
|
|
41
|
-
adv_attr_accessor :mime_version
|
|
42
|
-
|
|
43
|
-
# The recipient addresses for the message, either as a string (for a single
|
|
44
|
-
# address) or an array (for multiple addresses).
|
|
45
|
-
adv_attr_accessor :recipients
|
|
46
|
-
|
|
47
|
-
# The date on which the message was sent. If not set (the default), the
|
|
48
|
-
# header will be set by the delivery agent.
|
|
49
|
-
adv_attr_accessor :sent_on
|
|
50
|
-
|
|
51
|
-
# Specify the subject of the message.
|
|
52
|
-
adv_attr_accessor :subject
|
|
53
|
-
|
|
54
|
-
# Specify the template name to use for current message. This is the "base"
|
|
55
|
-
# template name, without the extension or directory, and may be used to
|
|
56
|
-
# have multiple mailer methods share the same template.
|
|
57
|
-
adv_attr_accessor :template
|
|
58
|
-
|
|
59
|
-
# Override the mailer name, which defaults to an inflected version of the
|
|
60
|
-
# mailer's class name. If you want to use a template in a non-standard
|
|
61
|
-
# location, you can use this to specify that location.
|
|
62
|
-
adv_attr_accessor :mailer_name
|
|
63
|
-
|
|
64
|
-
# Define the body of the message. This is either a Hash (in which case it
|
|
65
|
-
# specifies the variables to pass to the template when it is rendered),
|
|
66
|
-
# or a string, in which case it specifies the actual text of the message.
|
|
67
|
-
adv_attr_accessor :body
|
|
68
|
-
|
|
69
|
-
# Alias controller_path to mailer_name so render :partial in views work.
|
|
70
|
-
alias :controller_path :mailer_name
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def process(method_name, *args)
|
|
74
|
-
initialize_defaults(method_name)
|
|
75
|
-
super
|
|
76
|
-
unless @mail_was_called
|
|
77
|
-
create_parts
|
|
78
|
-
create_mail
|
|
79
|
-
end
|
|
80
|
-
@_message
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
# Add a part to a multipart message, with the given content-type. The
|
|
84
|
-
# part itself is yielded to the block so that other properties (charset,
|
|
85
|
-
# body, headers, etc.) can be set on it.
|
|
86
|
-
def part(params)
|
|
87
|
-
params = {:content_type => params} if String === params
|
|
88
|
-
|
|
89
|
-
if custom_headers = params.delete(:headers)
|
|
90
|
-
params.merge!(custom_headers)
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
part = Mail::Part.new(params)
|
|
94
|
-
|
|
95
|
-
yield part if block_given?
|
|
96
|
-
@parts << part
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
# Add an attachment to a multipart message. This is simply a part with the
|
|
100
|
-
# content-disposition set to "attachment".
|
|
101
|
-
def attachment(params, &block)
|
|
102
|
-
params = { :content_type => params } if String === params
|
|
103
|
-
|
|
104
|
-
params[:content] ||= params.delete(:data) || params.delete(:body)
|
|
105
|
-
|
|
106
|
-
if params[:filename]
|
|
107
|
-
params = normalize_file_hash(params)
|
|
108
|
-
else
|
|
109
|
-
params = normalize_nonfile_hash(params)
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
part(params, &block)
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
protected
|
|
116
|
-
|
|
117
|
-
def normalize_nonfile_hash(params)
|
|
118
|
-
content_disposition = "attachment;"
|
|
119
|
-
|
|
120
|
-
mime_type = params.delete(:mime_type)
|
|
121
|
-
|
|
122
|
-
if content_type = params.delete(:content_type)
|
|
123
|
-
content_type = "#{mime_type || content_type};"
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
params[:body] = params.delete(:data) if params[:data]
|
|
127
|
-
|
|
128
|
-
{ :content_type => content_type,
|
|
129
|
-
:content_disposition => content_disposition }.merge(params)
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
def normalize_file_hash(params)
|
|
133
|
-
filename = File.basename(params.delete(:filename))
|
|
134
|
-
content_disposition = "attachment; filename=\"#{File.basename(filename)}\""
|
|
135
|
-
|
|
136
|
-
mime_type = params.delete(:mime_type)
|
|
137
|
-
|
|
138
|
-
if (content_type = params.delete(:content_type)) && (content_type !~ /filename=/)
|
|
139
|
-
content_type = "#{mime_type || content_type}; filename=\"#{filename}\""
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
params[:body] = params.delete(:data) if params[:data]
|
|
143
|
-
|
|
144
|
-
{ :content_type => content_type,
|
|
145
|
-
:content_disposition => content_disposition }.merge(params)
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
def create_mail
|
|
149
|
-
m = @_message
|
|
150
|
-
|
|
151
|
-
set_fields!({:subject => subject, :to => recipients, :from => from,
|
|
152
|
-
:bcc => bcc, :cc => cc, :reply_to => reply_to}, charset)
|
|
153
|
-
|
|
154
|
-
m.mime_version = mime_version unless mime_version.nil?
|
|
155
|
-
m.date = sent_on.to_time rescue sent_on if sent_on
|
|
156
|
-
|
|
157
|
-
@headers.each { |k, v| m[k] = v }
|
|
158
|
-
|
|
159
|
-
real_content_type, ctype_attrs = parse_content_type
|
|
160
|
-
main_type, sub_type = split_content_type(real_content_type)
|
|
161
|
-
|
|
162
|
-
if @parts.size == 1 && @parts.first.parts.empty?
|
|
163
|
-
m.content_type([main_type, sub_type, ctype_attrs])
|
|
164
|
-
m.body = @parts.first.body.encoded
|
|
165
|
-
else
|
|
166
|
-
@parts.each do |p|
|
|
167
|
-
m.add_part(p)
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
m.body.set_sort_order(@implicit_parts_order)
|
|
171
|
-
m.body.sort_parts!
|
|
172
|
-
|
|
173
|
-
if real_content_type =~ /multipart/
|
|
174
|
-
ctype_attrs.delete "charset"
|
|
175
|
-
m.content_type([main_type, sub_type, ctype_attrs])
|
|
176
|
-
end
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
wrap_delivery_behavior!
|
|
180
|
-
m.content_transfer_encoding = '8bit' unless m.body.only_us_ascii?
|
|
181
|
-
|
|
182
|
-
@_message
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
# Set up the default values for the various instance variables of this
|
|
186
|
-
# mailer. Subclasses may override this method to provide different
|
|
187
|
-
# defaults.
|
|
188
|
-
def initialize_defaults(method_name)
|
|
189
|
-
@charset ||= self.class.default[:charset].try(:dup)
|
|
190
|
-
@content_type ||= self.class.default[:content_type].try(:dup)
|
|
191
|
-
@implicit_parts_order ||= self.class.default[:parts_order].try(:dup)
|
|
192
|
-
@mime_version ||= self.class.default[:mime_version].try(:dup)
|
|
193
|
-
|
|
194
|
-
@mailer_name ||= self.class.mailer_name.dup
|
|
195
|
-
@template ||= method_name
|
|
196
|
-
@mail_was_called = false
|
|
197
|
-
|
|
198
|
-
@parts ||= []
|
|
199
|
-
@headers ||= {}
|
|
200
|
-
@sent_on ||= Time.now
|
|
201
|
-
@body ||= {}
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
def create_parts
|
|
205
|
-
if String === @body
|
|
206
|
-
@parts.unshift create_inline_part(@body)
|
|
207
|
-
elsif @parts.empty? || @parts.all? { |p| p.content_disposition =~ /^attachment/ }
|
|
208
|
-
lookup_context.find_all(@template, @mailer_name).each do |template|
|
|
209
|
-
self.formats = template.formats
|
|
210
|
-
@parts << create_inline_part(render(:template => template), template.mime_type)
|
|
211
|
-
end
|
|
212
|
-
|
|
213
|
-
if @parts.size > 1
|
|
214
|
-
@content_type = "multipart/alternative" if @content_type !~ /^multipart/
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
# If this is a multipart e-mail add the mime_version if it is not
|
|
218
|
-
# already set.
|
|
219
|
-
@mime_version ||= "1.0" if !@parts.empty?
|
|
220
|
-
end
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
def create_inline_part(body, mime_type=nil)
|
|
224
|
-
ct = mime_type || "text/plain"
|
|
225
|
-
main_type, sub_type = split_content_type(ct.to_s)
|
|
226
|
-
|
|
227
|
-
Mail::Part.new(
|
|
228
|
-
:content_type => [main_type, sub_type, {:charset => charset}],
|
|
229
|
-
:content_disposition => "inline",
|
|
230
|
-
:body => body
|
|
231
|
-
)
|
|
232
|
-
end
|
|
233
|
-
|
|
234
|
-
def set_fields!(headers, charset) #:nodoc:
|
|
235
|
-
m = @_message
|
|
236
|
-
m.charset = charset
|
|
237
|
-
m.subject ||= headers.delete(:subject) if headers[:subject]
|
|
238
|
-
m.to ||= headers.delete(:to) if headers[:to]
|
|
239
|
-
m.from ||= headers.delete(:from) if headers[:from]
|
|
240
|
-
m.cc ||= headers.delete(:cc) if headers[:cc]
|
|
241
|
-
m.bcc ||= headers.delete(:bcc) if headers[:bcc]
|
|
242
|
-
m.reply_to ||= headers.delete(:reply_to) if headers[:reply_to]
|
|
243
|
-
end
|
|
244
|
-
|
|
245
|
-
def split_content_type(ct)
|
|
246
|
-
ct.to_s.split("/")
|
|
247
|
-
end
|
|
248
|
-
|
|
249
|
-
def parse_content_type(defaults=nil)
|
|
250
|
-
if @content_type.blank?
|
|
251
|
-
[ nil, {} ]
|
|
252
|
-
else
|
|
253
|
-
ctype, *attrs = @content_type.split(/;\s*/)
|
|
254
|
-
attrs = attrs.inject({}) { |h,s| k,v = s.split(/\=/, 2); h[k] = v; h }
|
|
255
|
-
[ctype, {"charset" => @charset}.merge(attrs)]
|
|
256
|
-
end
|
|
257
|
-
end
|
|
258
|
-
end
|
|
259
|
-
end
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
module Mail
|
|
2
|
-
class Message
|
|
3
|
-
|
|
4
|
-
def set_content_type(*args)
|
|
5
|
-
ActiveSupport::Deprecation.warn('Message#set_content_type is deprecated, please just call ' <<
|
|
6
|
-
'Message#content_type with the same arguments', caller[0,2])
|
|
7
|
-
content_type(*args)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
alias :old_transfer_encoding :transfer_encoding
|
|
11
|
-
def transfer_encoding(value = nil)
|
|
12
|
-
if value
|
|
13
|
-
ActiveSupport::Deprecation.warn('Message#transfer_encoding is deprecated, please call ' <<
|
|
14
|
-
'Message#content_transfer_encoding with the same arguments', caller[0,2])
|
|
15
|
-
content_transfer_encoding(value)
|
|
16
|
-
else
|
|
17
|
-
old_transfer_encoding
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def transfer_encoding=(value)
|
|
22
|
-
ActiveSupport::Deprecation.warn('Message#transfer_encoding= is deprecated, please call ' <<
|
|
23
|
-
'Message#content_transfer_encoding= with the same arguments', caller[0,2])
|
|
24
|
-
self.content_transfer_encoding = value
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def original_filename
|
|
28
|
-
ActiveSupport::Deprecation.warn('Message#original_filename is deprecated, ' <<
|
|
29
|
-
'please call Message#filename', caller[0,2])
|
|
30
|
-
filename
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
end
|
|
34
|
-
end
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
class <%= class_name %> < ActionMailer::Base
|
|
2
|
-
default :from => "from@example.com"
|
|
3
|
-
<% for action in actions -%>
|
|
4
|
-
|
|
5
|
-
# Subject can be set in your I18n file at config/locales/en.yml
|
|
6
|
-
# with the following lookup:
|
|
7
|
-
#
|
|
8
|
-
# en.<%= file_path.gsub("/",".") %>.<%= action %>.subject
|
|
9
|
-
#
|
|
10
|
-
def <%= action %>
|
|
11
|
-
@greeting = "Hi"
|
|
12
|
-
|
|
13
|
-
mail :to => "to@example.org"
|
|
14
|
-
end
|
|
15
|
-
<% end -%>
|
|
16
|
-
end
|