actionmailer 7.0.8.7 → 7.2.2.1
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 +4 -4
- data/CHANGELOG.md +15 -148
- data/MIT-LICENSE +1 -1
- data/README.rdoc +2 -2
- data/lib/action_mailer/base.rb +63 -52
- data/lib/action_mailer/callbacks.rb +31 -0
- data/lib/action_mailer/delivery_methods.rb +4 -3
- data/lib/action_mailer/deprecator.rb +7 -0
- data/lib/action_mailer/form_builder.rb +37 -0
- data/lib/action_mailer/gem_version.rb +4 -4
- data/lib/action_mailer/inline_preview_interceptor.rb +2 -0
- data/lib/action_mailer/log_subscriber.rb +7 -2
- data/lib/action_mailer/mail_delivery_job.rb +7 -2
- data/lib/action_mailer/mail_helper.rb +2 -0
- data/lib/action_mailer/message_delivery.rb +20 -12
- data/lib/action_mailer/parameterized.rb +12 -8
- data/lib/action_mailer/preview.rb +8 -8
- data/lib/action_mailer/queued_delivery.rb +12 -0
- data/lib/action_mailer/railtie.rb +11 -16
- data/lib/action_mailer/rescuable.rb +2 -0
- data/lib/action_mailer/test_case.rb +9 -4
- data/lib/action_mailer/test_helper.rb +114 -11
- data/lib/action_mailer/version.rb +1 -1
- data/lib/action_mailer.rb +11 -2
- data/lib/rails/generators/mailer/USAGE +12 -8
- data/lib/rails/generators/mailer/templates/mailer.rb.tt +3 -1
- metadata +21 -65
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c11aff9a531baec43ef53e43297b9fad9b5b1320e15089a50882dea492089b3e
|
4
|
+
data.tar.gz: 36035769d7005800933e17050cc20451041da2704871f44fc3d1087eae452f44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b929b02d7ca792849fc3a6af4efe1331b3fd5db624ba5931adca0271d6b5faa201dd395b221b60fc7c8869b251b8ff8cb1f19131531bb88356684684c962c5a
|
7
|
+
data.tar.gz: a62791462cce39d377c74b5ce8df83dbb789d17cffc05036c3d149f04c3bc5212261ac144ec0d6148502f969094ecb896daf9e4af392a01d90fc6a2312dbc7a0
|
data/CHANGELOG.md
CHANGED
@@ -1,175 +1,42 @@
|
|
1
|
-
## Rails 7.
|
1
|
+
## Rails 7.2.2.1 (December 10, 2024) ##
|
2
2
|
|
3
3
|
* No changes.
|
4
4
|
|
5
5
|
|
6
|
-
## Rails 7.
|
7
|
-
|
8
|
-
* Fix NoMethodError in `block_format` helper
|
9
|
-
|
10
|
-
*Michael Leimstaedtner*
|
11
|
-
|
12
|
-
|
13
|
-
## Rails 7.0.8.5 (October 15, 2024) ##
|
14
|
-
|
15
|
-
* Avoid regex backtracking in `block_format` helper
|
16
|
-
|
17
|
-
[CVE-2024-47889]
|
18
|
-
|
19
|
-
|
20
|
-
## Rails 7.0.8.4 (June 04, 2024) ##
|
21
|
-
|
22
|
-
* No changes.
|
23
|
-
|
24
|
-
|
25
|
-
## Rails 7.0.8.3 (May 17, 2024) ##
|
26
|
-
|
27
|
-
* No changes.
|
28
|
-
|
29
|
-
|
30
|
-
## Rails 7.0.8.2 (May 16, 2024) ##
|
31
|
-
|
32
|
-
* No changes.
|
33
|
-
|
34
|
-
|
35
|
-
## Rails 7.0.8.1 (February 21, 2024) ##
|
36
|
-
|
37
|
-
* No changes.
|
38
|
-
|
39
|
-
|
40
|
-
## Rails 7.0.8 (September 09, 2023) ##
|
41
|
-
|
42
|
-
* No changes.
|
43
|
-
|
44
|
-
|
45
|
-
## Rails 7.0.7.2 (August 22, 2023) ##
|
46
|
-
|
47
|
-
* No changes.
|
48
|
-
|
49
|
-
|
50
|
-
## Rails 7.0.7.1 (August 22, 2023) ##
|
51
|
-
|
52
|
-
* No changes.
|
53
|
-
|
54
|
-
|
55
|
-
## Rails 7.0.7 (August 09, 2023) ##
|
56
|
-
|
57
|
-
* No changes.
|
58
|
-
|
59
|
-
|
60
|
-
## Rails 7.0.6 (June 29, 2023) ##
|
61
|
-
|
62
|
-
* No changes.
|
63
|
-
|
64
|
-
|
65
|
-
## Rails 7.0.5.1 (June 26, 2023) ##
|
66
|
-
|
67
|
-
* No changes.
|
68
|
-
|
69
|
-
|
70
|
-
## Rails 7.0.5 (May 24, 2023) ##
|
71
|
-
|
72
|
-
* No changes.
|
73
|
-
|
74
|
-
|
75
|
-
## Rails 7.0.4.3 (March 13, 2023) ##
|
6
|
+
## Rails 7.2.2 (October 30, 2024) ##
|
76
7
|
|
77
8
|
* No changes.
|
78
9
|
|
79
10
|
|
80
|
-
## Rails 7.
|
81
|
-
|
82
|
-
* No changes.
|
83
|
-
|
84
|
-
|
85
|
-
## Rails 7.0.4.1 (January 17, 2023) ##
|
86
|
-
|
87
|
-
* No changes.
|
88
|
-
|
89
|
-
|
90
|
-
## Rails 7.0.4 (September 09, 2022) ##
|
91
|
-
|
92
|
-
* No changes.
|
93
|
-
|
94
|
-
|
95
|
-
## Rails 7.0.3.1 (July 12, 2022) ##
|
96
|
-
|
97
|
-
* No changes.
|
98
|
-
|
99
|
-
|
100
|
-
## Rails 7.0.3 (May 09, 2022) ##
|
101
|
-
|
102
|
-
* No changes.
|
103
|
-
|
104
|
-
|
105
|
-
## Rails 7.0.2.4 (April 26, 2022) ##
|
106
|
-
|
107
|
-
* No changes.
|
108
|
-
|
109
|
-
|
110
|
-
## Rails 7.0.2.3 (March 08, 2022) ##
|
111
|
-
|
112
|
-
* No changes.
|
113
|
-
|
114
|
-
|
115
|
-
## Rails 7.0.2.2 (February 11, 2022) ##
|
116
|
-
|
117
|
-
* No changes.
|
118
|
-
|
119
|
-
|
120
|
-
## Rails 7.0.2.1 (February 11, 2022) ##
|
121
|
-
|
122
|
-
* No changes.
|
123
|
-
|
124
|
-
|
125
|
-
## Rails 7.0.2 (February 08, 2022) ##
|
126
|
-
|
127
|
-
* No changes.
|
11
|
+
## Rails 7.2.1.2 (October 23, 2024) ##
|
128
12
|
|
13
|
+
* Fix NoMethodError in `block_format` helper
|
129
14
|
|
130
|
-
|
15
|
+
*Michael Leimstaedtner*
|
131
16
|
|
132
|
-
* Keep configuration of `smtp_settings` consistent between 6.1 and 7.0.
|
133
17
|
|
134
|
-
|
18
|
+
## Rails 7.2.1.1 (October 15, 2024) ##
|
135
19
|
|
20
|
+
* Avoid regex backtracking in `block_format` helper
|
136
21
|
|
137
|
-
|
22
|
+
[CVE-2024-47889]
|
138
23
|
|
139
|
-
*
|
24
|
+
*John Hawthorn*
|
140
25
|
|
141
26
|
|
142
|
-
## Rails 7.
|
27
|
+
## Rails 7.2.1 (August 22, 2024) ##
|
143
28
|
|
144
29
|
* No changes.
|
145
30
|
|
146
31
|
|
147
|
-
## Rails 7.
|
148
|
-
|
149
|
-
* No changes.
|
150
|
-
|
151
|
-
## Rails 7.0.0.rc1 (December 06, 2021) ##
|
32
|
+
## Rails 7.2.0 (August 09, 2024) ##
|
152
33
|
|
153
|
-
* Remove deprecated `
|
154
|
-
in favor of `ActionMailer::MailDeliveryJob`.
|
34
|
+
* Remove deprecated params via `:args` for `assert_enqueued_email_with`.
|
155
35
|
|
156
36
|
*Rafael Mendonça França*
|
157
37
|
|
158
|
-
*
|
159
|
-
|
160
|
-
*Thomas Hutterer*
|
161
|
-
|
162
|
-
|
163
|
-
## Rails 7.0.0.alpha2 (September 15, 2021) ##
|
164
|
-
|
165
|
-
* No changes.
|
166
|
-
|
167
|
-
|
168
|
-
## Rails 7.0.0.alpha1 (September 15, 2021) ##
|
169
|
-
|
170
|
-
* Configures a default of 5 for both `open_timeout` and `read_timeout` for SMTP Settings.
|
171
|
-
|
172
|
-
*André Luis Leal Cardoso Junior*
|
38
|
+
* Remove deprecated `config.action_mailer.preview_path`.
|
173
39
|
|
40
|
+
*Rafael Mendonça França*
|
174
41
|
|
175
|
-
Please check [
|
42
|
+
Please check [7-1-stable](https://github.com/rails/rails/blob/7-1-stable/actionmailer/CHANGELOG.md) for previous changes.
|
data/MIT-LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -13,7 +13,7 @@ Additionally, an Action Mailer class can be used to process incoming email,
|
|
13
13
|
such as allowing a blog to accept new posts from an email (which could even
|
14
14
|
have been sent from a phone).
|
15
15
|
|
16
|
-
You can read more about Action Mailer in the {Action Mailer Basics}[https://
|
16
|
+
You can read more about Action Mailer in the {Action Mailer Basics}[https://guides.rubyonrails.org/action_mailer_basics.html] guide.
|
17
17
|
|
18
18
|
== Sending emails
|
19
19
|
|
@@ -78,7 +78,7 @@ Or you can just chain the methods together like:
|
|
78
78
|
|
79
79
|
It is possible to set default values that will be used in every method in your
|
80
80
|
Action Mailer class. To implement this functionality, you just call the public
|
81
|
-
class method +default+ which you get for free from
|
81
|
+
class method +default+ which you get for free from ActionMailer::Base.
|
82
82
|
This method accepts a Hash as the parameter. You can use any of the headers,
|
83
83
|
email messages have, like +:from+ as the key. You can also pass in a string as
|
84
84
|
the key, like "Content-Type", but Action Mailer does this out of the box for you,
|
data/lib/action_mailer/base.rb
CHANGED
@@ -10,16 +10,18 @@ require "action_mailer/log_subscriber"
|
|
10
10
|
require "action_mailer/rescuable"
|
11
11
|
|
12
12
|
module ActionMailer
|
13
|
+
# = Action Mailer \Base
|
14
|
+
#
|
13
15
|
# Action Mailer allows you to send email from your application using a mailer model and views.
|
14
16
|
#
|
15
|
-
#
|
17
|
+
# == Mailer Models
|
16
18
|
#
|
17
19
|
# To use Action Mailer, you need to create a mailer model.
|
18
20
|
#
|
19
21
|
# $ bin/rails generate mailer Notifier
|
20
22
|
#
|
21
23
|
# The generated model inherits from <tt>ApplicationMailer</tt> which in turn
|
22
|
-
# inherits from
|
24
|
+
# inherits from +ActionMailer::Base+. A mailer model defines methods
|
23
25
|
# used to generate an email message. In these methods, you can set up variables to be used in
|
24
26
|
# the mailer views, options on the mail itself such as the <tt>:from</tt> address, and attachments.
|
25
27
|
#
|
@@ -56,7 +58,7 @@ module ActionMailer
|
|
56
58
|
#
|
57
59
|
# * <tt>mail</tt> - Allows you to specify email to be sent.
|
58
60
|
#
|
59
|
-
# The hash passed to the mail method allows you to specify any header that a
|
61
|
+
# The hash passed to the mail method allows you to specify any header that a +Mail::Message+
|
60
62
|
# will accept (any valid email header including optional fields).
|
61
63
|
#
|
62
64
|
# The +mail+ method, if not passed a block, will inspect your views and send all the views with
|
@@ -84,7 +86,7 @@ module ActionMailer
|
|
84
86
|
# format.html { render "some_other_template" }
|
85
87
|
# end
|
86
88
|
#
|
87
|
-
#
|
89
|
+
# == Mailer views
|
88
90
|
#
|
89
91
|
# Like Action Controller, each mailer class has a corresponding view directory in which each
|
90
92
|
# method of the class looks for a template with its name.
|
@@ -112,7 +114,7 @@ module ActionMailer
|
|
112
114
|
# <%= truncate(@note.body, length: 25) %>
|
113
115
|
#
|
114
116
|
#
|
115
|
-
#
|
117
|
+
# == Generating URLs
|
116
118
|
#
|
117
119
|
# URLs can be generated in mailer views using <tt>url_for</tt> or named routes. Unlike controllers from
|
118
120
|
# Action Pack, the mailer instance doesn't have any context about the incoming request, so you'll need
|
@@ -140,7 +142,7 @@ module ActionMailer
|
|
140
142
|
#
|
141
143
|
# By default when <tt>config.force_ssl</tt> is +true+, URLs generated for hosts will use the HTTPS protocol.
|
142
144
|
#
|
143
|
-
#
|
145
|
+
# == Sending mail
|
144
146
|
#
|
145
147
|
# Once a mailer action and template are defined, you can deliver your message or defer its creation and
|
146
148
|
# delivery for later:
|
@@ -150,7 +152,7 @@ module ActionMailer
|
|
150
152
|
# mail.deliver_now # generates and sends the email now
|
151
153
|
#
|
152
154
|
# The ActionMailer::MessageDelivery class is a wrapper around a delegate that will call
|
153
|
-
# your method to generate the mail. If you want direct access to the delegator, or
|
155
|
+
# your method to generate the mail. If you want direct access to the delegator, or +Mail::Message+,
|
154
156
|
# you can call the <tt>message</tt> method on the ActionMailer::MessageDelivery object.
|
155
157
|
#
|
156
158
|
# NotifierMailer.welcome(User.first).message # => a Mail::Message object
|
@@ -165,7 +167,7 @@ module ActionMailer
|
|
165
167
|
# You never instantiate your mailer class. Rather, you just call the method you defined on the class itself.
|
166
168
|
# All instance methods are expected to return a message object to be sent.
|
167
169
|
#
|
168
|
-
#
|
170
|
+
# == Multipart Emails
|
169
171
|
#
|
170
172
|
# Multipart messages can also be used implicitly because Action Mailer will automatically detect and use
|
171
173
|
# multipart templates, where each template is named after the name of the action, followed by the content
|
@@ -186,7 +188,7 @@ module ActionMailer
|
|
186
188
|
# This means that you'll have to manually add each part to the email and set the content type of the email
|
187
189
|
# to <tt>multipart/alternative</tt>.
|
188
190
|
#
|
189
|
-
#
|
191
|
+
# == Attachments
|
190
192
|
#
|
191
193
|
# Sending attachment in emails is easy:
|
192
194
|
#
|
@@ -213,7 +215,7 @@ module ActionMailer
|
|
213
215
|
# end
|
214
216
|
# end
|
215
217
|
#
|
216
|
-
# You can also send attachments with
|
218
|
+
# You can also send attachments with HTML template, in this case you need to add body, attachments,
|
217
219
|
# and custom content type like this:
|
218
220
|
#
|
219
221
|
# class NotifierMailer < ApplicationMailer
|
@@ -226,7 +228,7 @@ module ActionMailer
|
|
226
228
|
# end
|
227
229
|
# end
|
228
230
|
#
|
229
|
-
#
|
231
|
+
# == Inline Attachments
|
230
232
|
#
|
231
233
|
# You can also specify that a file should be displayed inline with other HTML. This is useful
|
232
234
|
# if you want to display a corporate logo or a photo.
|
@@ -252,7 +254,7 @@ module ActionMailer
|
|
252
254
|
#
|
253
255
|
# <%= image_tag attachments['photo.png'].url, alt: 'Our Photo', class: 'photo' -%>
|
254
256
|
#
|
255
|
-
#
|
257
|
+
# == Observing and Intercepting Mails
|
256
258
|
#
|
257
259
|
# Action Mailer provides hooks into the Mail observer and interceptor methods. These allow you to
|
258
260
|
# register classes that are called during the mail delivery life cycle.
|
@@ -263,9 +265,9 @@ module ActionMailer
|
|
263
265
|
# An interceptor class must implement the <tt>:delivering_email(message)</tt> method which will be
|
264
266
|
# called before the email is sent, allowing you to make modifications to the email before it hits
|
265
267
|
# the delivery agents. Your class should make any needed modifications directly to the passed
|
266
|
-
# in
|
268
|
+
# in +Mail::Message+ instance.
|
267
269
|
#
|
268
|
-
#
|
270
|
+
# == Default \Hash
|
269
271
|
#
|
270
272
|
# Action Mailer provides some intelligent defaults for your emails, these are usually specified in a
|
271
273
|
# default method inside the class definition:
|
@@ -274,15 +276,15 @@ module ActionMailer
|
|
274
276
|
# default sender: 'system@example.com'
|
275
277
|
# end
|
276
278
|
#
|
277
|
-
# You can pass in any header value that a
|
278
|
-
#
|
279
|
+
# You can pass in any header value that a +Mail::Message+ accepts. Out of the box,
|
280
|
+
# +ActionMailer::Base+ sets the following:
|
279
281
|
#
|
280
282
|
# * <tt>mime_version: "1.0"</tt>
|
281
283
|
# * <tt>charset: "UTF-8"</tt>
|
282
284
|
# * <tt>content_type: "text/plain"</tt>
|
283
285
|
# * <tt>parts_order: [ "text/plain", "text/enriched", "text/html" ]</tt>
|
284
286
|
#
|
285
|
-
# <tt>parts_order</tt> and <tt>charset</tt> are not actually valid
|
287
|
+
# <tt>parts_order</tt> and <tt>charset</tt> are not actually valid +Mail::Message+ header fields,
|
286
288
|
# but Action Mailer translates them appropriately and sets the correct values.
|
287
289
|
#
|
288
290
|
# As you can pass in any header, you need to either quote the header as a string, or pass it in as
|
@@ -314,14 +316,16 @@ module ActionMailer
|
|
314
316
|
#
|
315
317
|
# config.action_mailer.default_options = { from: "no-reply@example.org" }
|
316
318
|
#
|
317
|
-
#
|
319
|
+
# == \Callbacks
|
318
320
|
#
|
319
|
-
# You can specify callbacks using <tt>before_action</tt> and <tt>after_action</tt> for configuring your messages
|
320
|
-
#
|
321
|
-
#
|
321
|
+
# You can specify callbacks using <tt>before_action</tt> and <tt>after_action</tt> for configuring your messages,
|
322
|
+
# and using <tt>before_deliver</tt> and <tt>after_deliver</tt> for wrapping the delivery process.
|
323
|
+
# For example, when you want to add default inline attachments and log delivery for all messages
|
324
|
+
# sent out by a certain mailer class:
|
322
325
|
#
|
323
326
|
# class NotifierMailer < ApplicationMailer
|
324
327
|
# before_action :add_inline_attachment!
|
328
|
+
# after_deliver :log_delivery
|
325
329
|
#
|
326
330
|
# def welcome
|
327
331
|
# mail
|
@@ -331,9 +335,13 @@ module ActionMailer
|
|
331
335
|
# def add_inline_attachment!
|
332
336
|
# attachments.inline["footer.jpg"] = File.read('/path/to/filename.jpg')
|
333
337
|
# end
|
338
|
+
#
|
339
|
+
# def log_delivery
|
340
|
+
# Rails.logger.info "Sent email with message id '#{message.message_id}' at #{Time.current}."
|
341
|
+
# end
|
334
342
|
# end
|
335
343
|
#
|
336
|
-
#
|
344
|
+
# Action callbacks in Action Mailer are implemented using
|
337
345
|
# AbstractController::Callbacks, so you can define and configure
|
338
346
|
# callbacks in the same manner that you would use callbacks in classes that
|
339
347
|
# inherit from ActionController::Base.
|
@@ -342,7 +350,7 @@ module ActionMailer
|
|
342
350
|
# using <tt>before_action</tt> rather than <tt>after_action</tt> in your
|
343
351
|
# Action Mailer classes so that headers are parsed properly.
|
344
352
|
#
|
345
|
-
#
|
353
|
+
# == Rescuing Errors
|
346
354
|
#
|
347
355
|
# +rescue+ blocks inside of a mailer method cannot rescue errors that occur
|
348
356
|
# outside of rendering -- for example, record deserialization errors in a
|
@@ -365,10 +373,10 @@ module ActionMailer
|
|
365
373
|
# end
|
366
374
|
# end
|
367
375
|
#
|
368
|
-
#
|
376
|
+
# == Previewing emails
|
369
377
|
#
|
370
378
|
# You can preview your email templates visually by adding a mailer preview file to the
|
371
|
-
# <tt>ActionMailer::Base.
|
379
|
+
# <tt>ActionMailer::Base.preview_paths</tt>. Since most emails do something interesting
|
372
380
|
# with database data, you'll need to write some scenarios to load messages with fake data:
|
373
381
|
#
|
374
382
|
# class NotifierMailerPreview < ActionMailer::Preview
|
@@ -377,12 +385,12 @@ module ActionMailer
|
|
377
385
|
# end
|
378
386
|
# end
|
379
387
|
#
|
380
|
-
# Methods must return a
|
388
|
+
# Methods must return a +Mail::Message+ object which can be generated by calling the mailer
|
381
389
|
# method without the additional <tt>deliver_now</tt> / <tt>deliver_later</tt>. The location of the
|
382
|
-
# mailer
|
390
|
+
# mailer preview directories can be configured using the <tt>preview_paths</tt> option which has a default
|
383
391
|
# of <tt>test/mailers/previews</tt>:
|
384
392
|
#
|
385
|
-
# config.action_mailer.
|
393
|
+
# config.action_mailer.preview_paths << "#{Rails.root}/lib/mailer_previews"
|
386
394
|
#
|
387
395
|
# An overview of all previews is accessible at <tt>http://localhost:3000/rails/mailers</tt>
|
388
396
|
# on a running development server instance.
|
@@ -402,7 +410,7 @@ module ActionMailer
|
|
402
410
|
# and <tt>register_preview_interceptor</tt> if they should operate on both sending and
|
403
411
|
# previewing emails.
|
404
412
|
#
|
405
|
-
#
|
413
|
+
# == Configuration options
|
406
414
|
#
|
407
415
|
# These options are specified on the class level, like
|
408
416
|
# <tt>ActionMailer::Base.raise_delivery_errors = true</tt>
|
@@ -425,20 +433,21 @@ module ActionMailer
|
|
425
433
|
# This is a symbol and one of <tt>:plain</tt> (will send the password Base64 encoded), <tt>:login</tt> (will
|
426
434
|
# send the password Base64 encoded) or <tt>:cram_md5</tt> (combines a Challenge/Response mechanism to exchange
|
427
435
|
# information and a cryptographic Message Digest 5 algorithm to hash important information)
|
428
|
-
# * <tt>:enable_starttls</tt> - Use STARTTLS when connecting to your SMTP server and fail if unsupported. Defaults
|
436
|
+
# * <tt>:enable_starttls</tt> - Use STARTTLS when connecting to your SMTP server and fail if unsupported. Defaults
|
437
|
+
# to <tt>false</tt>. Requires at least version 2.7 of the Mail gem.
|
429
438
|
# * <tt>:enable_starttls_auto</tt> - Detects if STARTTLS is enabled in your SMTP server and starts
|
430
439
|
# to use it. Defaults to <tt>true</tt>.
|
431
440
|
# * <tt>:openssl_verify_mode</tt> - When using TLS, you can set how OpenSSL checks the certificate. This is
|
432
441
|
# really useful if you need to validate a self-signed and/or a wildcard certificate. You can use the name
|
433
442
|
# of an OpenSSL verify constant (<tt>'none'</tt> or <tt>'peer'</tt>) or directly the constant
|
434
|
-
# (
|
443
|
+
# (+OpenSSL::SSL::VERIFY_NONE+ or +OpenSSL::SSL::VERIFY_PEER+).
|
435
444
|
# * <tt>:ssl/:tls</tt> Enables the SMTP connection to use SMTP/TLS (SMTPS: SMTP over direct TLS connection)
|
436
445
|
# * <tt>:open_timeout</tt> Number of seconds to wait while attempting to open a connection.
|
437
446
|
# * <tt>:read_timeout</tt> Number of seconds to wait until timing-out a read(2) call.
|
438
447
|
#
|
439
448
|
# * <tt>sendmail_settings</tt> - Allows you to override options for the <tt>:sendmail</tt> delivery method.
|
440
449
|
# * <tt>:location</tt> - The location of the sendmail executable. Defaults to <tt>/usr/sbin/sendmail</tt>.
|
441
|
-
# * <tt>:arguments</tt> - The command line arguments. Defaults to <tt
|
450
|
+
# * <tt>:arguments</tt> - The command line arguments. Defaults to <tt>%w[ -i ]</tt> with <tt>-f sender@address</tt>
|
442
451
|
# added automatically before the message is sent.
|
443
452
|
#
|
444
453
|
# * <tt>file_settings</tt> - Allows you to override options for the <tt>:file</tt> delivery method.
|
@@ -459,15 +468,19 @@ module ActionMailer
|
|
459
468
|
# * <tt>deliveries</tt> - Keeps an array of all the emails sent out through the Action Mailer with
|
460
469
|
# <tt>delivery_method :test</tt>. Most useful for unit and functional testing.
|
461
470
|
#
|
462
|
-
# * <tt>delivery_job</tt> - The job class used with <tt>deliver_later</tt>.
|
463
|
-
# +ActionMailer::MailDeliveryJob+.
|
471
|
+
# * <tt>delivery_job</tt> - The job class used with <tt>deliver_later</tt>. Mailers can set this to use a
|
472
|
+
# custom delivery job. Defaults to +ActionMailer::MailDeliveryJob+.
|
464
473
|
#
|
465
|
-
# * <tt>deliver_later_queue_name</tt> - The name
|
474
|
+
# * <tt>deliver_later_queue_name</tt> - The queue name used by <tt>deliver_later</tt> with the default
|
475
|
+
# <tt>delivery_job</tt>. Mailers can set this to use a custom queue name.
|
466
476
|
class Base < AbstractController::Base
|
477
|
+
include Callbacks
|
467
478
|
include DeliveryMethods
|
479
|
+
include QueuedDelivery
|
468
480
|
include Rescuable
|
469
481
|
include Parameterized
|
470
482
|
include Previews
|
483
|
+
include FormBuilder
|
471
484
|
|
472
485
|
abstract!
|
473
486
|
|
@@ -486,7 +499,6 @@ module ActionMailer
|
|
486
499
|
|
487
500
|
helper ActionMailer::MailHelper
|
488
501
|
|
489
|
-
class_attribute :delivery_job, default: ::ActionMailer::MailDeliveryJob
|
490
502
|
class_attribute :default_params, default: {
|
491
503
|
mime_version: "1.0",
|
492
504
|
charset: "UTF-8",
|
@@ -576,11 +588,11 @@ module ActionMailer
|
|
576
588
|
# config.action_mailer.default_options = { from: "no-reply@example.org" }
|
577
589
|
alias :default_options= :default
|
578
590
|
|
579
|
-
# Wraps an email delivery inside of
|
591
|
+
# Wraps an email delivery inside of ActiveSupport::Notifications instrumentation.
|
580
592
|
#
|
581
|
-
# This method is actually called by the
|
582
|
-
# through a callback when you call <tt>:deliver</tt> on the
|
583
|
-
# calling +deliver_mail+ directly and passing a
|
593
|
+
# This method is actually called by the +Mail::Message+ object itself
|
594
|
+
# through a callback when you call <tt>:deliver</tt> on the +Mail::Message+,
|
595
|
+
# calling +deliver_mail+ directly and passing a +Mail::Message+ will do
|
584
596
|
# nothing except tell the logger you sent the email.
|
585
597
|
def deliver_mail(mail) # :nodoc:
|
586
598
|
ActiveSupport::Notifications.instrument("deliver.action_mailer") do |payload|
|
@@ -613,17 +625,16 @@ module ActionMailer
|
|
613
625
|
payload[:perform_deliveries] = mail.perform_deliveries
|
614
626
|
end
|
615
627
|
|
616
|
-
def method_missing(method_name,
|
617
|
-
if action_methods.include?(method_name.
|
618
|
-
MessageDelivery.new(self, method_name,
|
628
|
+
def method_missing(method_name, ...)
|
629
|
+
if action_methods.include?(method_name.name)
|
630
|
+
MessageDelivery.new(self, method_name, ...)
|
619
631
|
else
|
620
632
|
super
|
621
633
|
end
|
622
634
|
end
|
623
|
-
ruby2_keywords(:method_missing)
|
624
635
|
|
625
636
|
def respond_to_missing?(method, include_all = false)
|
626
|
-
action_methods.include?(method.
|
637
|
+
action_methods.include?(method.name) || super
|
627
638
|
end
|
628
639
|
end
|
629
640
|
|
@@ -657,7 +668,7 @@ module ActionMailer
|
|
657
668
|
true
|
658
669
|
end
|
659
670
|
|
660
|
-
def method_missing(
|
671
|
+
def method_missing(...)
|
661
672
|
nil
|
662
673
|
end
|
663
674
|
end
|
@@ -674,18 +685,18 @@ module ActionMailer
|
|
674
685
|
self.class.email_address_with_name(address, name)
|
675
686
|
end
|
676
687
|
|
677
|
-
# Allows you to pass random and unusual headers to the new
|
688
|
+
# Allows you to pass random and unusual headers to the new +Mail::Message+
|
678
689
|
# object which will add them to itself.
|
679
690
|
#
|
680
691
|
# headers['X-Special-Domain-Specific-Header'] = "SecretValue"
|
681
692
|
#
|
682
693
|
# You can also pass a hash into headers of header field names and values,
|
683
|
-
# which will then be set on the
|
694
|
+
# which will then be set on the +Mail::Message+ object:
|
684
695
|
#
|
685
696
|
# headers 'X-Special-Domain-Specific-Header' => "SecretValue",
|
686
697
|
# 'In-Reply-To' => incoming.message_id
|
687
698
|
#
|
688
|
-
# The resulting
|
699
|
+
# The resulting +Mail::Message+ will have the following in its header:
|
689
700
|
#
|
690
701
|
# X-Special-Domain-Specific-Header: SecretValue
|
691
702
|
#
|
@@ -772,7 +783,7 @@ module ActionMailer
|
|
772
783
|
# the most used headers in an email message, these are:
|
773
784
|
#
|
774
785
|
# * +:subject+ - The subject of the message, if this is omitted, Action Mailer will
|
775
|
-
# ask the Rails I18n class for a translated +:subject+ in the scope of
|
786
|
+
# ask the \Rails I18n class for a translated +:subject+ in the scope of
|
776
787
|
# <tt>[mailer_scope, action_name]</tt> or if this is missing, will translate the
|
777
788
|
# humanized version of the +action_name+
|
778
789
|
# * +:to+ - Who the message is destined for, can be a string of addresses, or an array
|
@@ -809,7 +820,7 @@ module ActionMailer
|
|
809
820
|
# templates in the view paths using by default the mailer name and the
|
810
821
|
# method name that it is being called from, it will then create parts for
|
811
822
|
# each of these templates intelligently, making educated guesses on correct
|
812
|
-
# content type and sequence, and return a fully prepared
|
823
|
+
# content type and sequence, and return a fully prepared +Mail::Message+
|
813
824
|
# ready to call <tt>:deliver</tt> on to send.
|
814
825
|
#
|
815
826
|
# For example:
|
@@ -918,7 +929,7 @@ module ActionMailer
|
|
918
929
|
end
|
919
930
|
end
|
920
931
|
|
921
|
-
# Translates the +subject+ using Rails I18n class under <tt>[mailer_scope, action_name]</tt> scope.
|
932
|
+
# Translates the +subject+ using \Rails I18n class under <tt>[mailer_scope, action_name]</tt> scope.
|
922
933
|
# If it does not find a translation for the +subject+ under the specified scope it will default to a
|
923
934
|
# humanized version of the <tt>action_name</tt>.
|
924
935
|
# If the subject has interpolations, you can pass them through the +interpolations+ parameter.
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActionMailer
|
4
|
+
module Callbacks
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
include ActiveSupport::Callbacks
|
9
|
+
define_callbacks :deliver, skip_after_callbacks_if_terminated: true
|
10
|
+
end
|
11
|
+
|
12
|
+
module ClassMethods
|
13
|
+
# Defines a callback that will get called right before the
|
14
|
+
# message is sent to the delivery method.
|
15
|
+
def before_deliver(*filters, &blk)
|
16
|
+
set_callback(:deliver, :before, *filters, &blk)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Defines a callback that will get called right after the
|
20
|
+
# message's delivery method is finished.
|
21
|
+
def after_deliver(*filters, &blk)
|
22
|
+
set_callback(:deliver, :after, *filters, &blk)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Defines a callback that will get called around the message's deliver method.
|
26
|
+
def around_deliver(*filters, &blk)
|
27
|
+
set_callback(:deliver, :around, *filters, &blk)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -3,6 +3,8 @@
|
|
3
3
|
require "tmpdir"
|
4
4
|
|
5
5
|
module ActionMailer
|
6
|
+
# = Action Mailer \DeliveryMethods
|
7
|
+
#
|
6
8
|
# This module handles everything related to mail delivery, from registering
|
7
9
|
# new delivery methods to configuring the mail object to be sent.
|
8
10
|
module DeliveryMethods
|
@@ -12,7 +14,6 @@ module ActionMailer
|
|
12
14
|
# Do not make this inheritable, because we always want it to propagate
|
13
15
|
cattr_accessor :raise_delivery_errors, default: true
|
14
16
|
cattr_accessor :perform_deliveries, default: true
|
15
|
-
cattr_accessor :deliver_later_queue_name, default: :mailers
|
16
17
|
|
17
18
|
class_attribute :delivery_methods, default: {}.freeze
|
18
19
|
class_attribute :delivery_method, default: :smtp
|
@@ -31,7 +32,7 @@ module ActionMailer
|
|
31
32
|
|
32
33
|
add_delivery_method :sendmail, Mail::Sendmail,
|
33
34
|
location: "/usr/sbin/sendmail",
|
34
|
-
arguments:
|
35
|
+
arguments: %w[-i]
|
35
36
|
|
36
37
|
add_delivery_method :test, Mail::TestMailer
|
37
38
|
end
|
@@ -46,7 +47,7 @@ module ActionMailer
|
|
46
47
|
#
|
47
48
|
# add_delivery_method :sendmail, Mail::Sendmail,
|
48
49
|
# location: '/usr/sbin/sendmail',
|
49
|
-
# arguments:
|
50
|
+
# arguments: %w[ -i ]
|
50
51
|
def add_delivery_method(symbol, klass, default_options = {})
|
51
52
|
class_attribute(:"#{symbol}_settings") unless respond_to?(:"#{symbol}_settings")
|
52
53
|
public_send(:"#{symbol}_settings=", default_options)
|