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.
Files changed (36) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +219 -0
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +49 -55
  5. data/lib/action_mailer/base.rb +688 -387
  6. data/lib/action_mailer/callbacks.rb +31 -0
  7. data/lib/action_mailer/collector.rb +11 -9
  8. data/lib/action_mailer/delivery_methods.rb +35 -37
  9. data/lib/action_mailer/deprecator.rb +7 -0
  10. data/lib/action_mailer/form_builder.rb +37 -0
  11. data/lib/action_mailer/gem_version.rb +17 -0
  12. data/lib/action_mailer/inline_preview_interceptor.rb +59 -0
  13. data/lib/action_mailer/log_subscriber.rb +30 -8
  14. data/lib/action_mailer/mail_delivery_job.rb +48 -0
  15. data/lib/action_mailer/mail_helper.rb +59 -18
  16. data/lib/action_mailer/message_delivery.rb +156 -0
  17. data/lib/action_mailer/parameterized.rb +156 -0
  18. data/lib/action_mailer/preview.rb +166 -0
  19. data/lib/action_mailer/queued_delivery.rb +12 -0
  20. data/lib/action_mailer/railtie.rb +75 -7
  21. data/lib/action_mailer/rescuable.rb +33 -0
  22. data/lib/action_mailer/test_case.rb +75 -25
  23. data/lib/action_mailer/test_helper.rb +238 -15
  24. data/lib/action_mailer/version.rb +8 -7
  25. data/lib/action_mailer.rb +45 -18
  26. data/lib/rails/generators/mailer/USAGE +13 -8
  27. data/lib/rails/generators/mailer/mailer_generator.rb +26 -4
  28. data/lib/rails/generators/mailer/templates/application_mailer.rb.tt +6 -0
  29. data/lib/rails/generators/mailer/templates/mailer.rb.tt +17 -0
  30. metadata +175 -87
  31. data/CHANGELOG +0 -424
  32. data/lib/action_mailer/adv_attr_accessor.rb +0 -26
  33. data/lib/action_mailer/deprecated_api.rb +0 -147
  34. data/lib/action_mailer/old_api.rb +0 -259
  35. data/lib/action_mailer/tmail_compat.rb +0 -34
  36. data/lib/rails/generators/mailer/templates/mailer.rb +0 -16
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e78a52de8bad55a81cd6f6f15707bed0b76fc47cabc0df12f2c8a4580ff9a174
4
+ data.tar.gz: d4369407e030f290b5e851408de29433bd4a04dba387eeeb06a2b85c859c74e8
5
+ SHA512:
6
+ metadata.gz: 4c0ff468dfba324450a002cc2bdc63cad4f5cfba0915e9700e63df7f4d288e02e75533b0bf78a5324f8119fec74568b5a51b485f0ae54c7522562f7fd8a7f377
7
+ data.tar.gz: cb0097798a1922759be6f46ffb887e5442a042f666a043c398b75ee4d30c5c55c520f48473f4de2186a302d90fbd5ddde5bc22c43c938422bc8fc9a42f87e227
data/CHANGELOG.md ADDED
@@ -0,0 +1,219 @@
1
+ ## Rails 7.1.6 (October 28, 2025) ##
2
+
3
+ * No changes.
4
+
5
+
6
+ ## Rails 7.1.5.2 (August 13, 2025) ##
7
+
8
+ * No changes.
9
+
10
+
11
+ ## Rails 7.1.5.1 (December 10, 2024) ##
12
+
13
+ * No changes.
14
+
15
+
16
+ ## Rails 7.1.5 (October 30, 2024) ##
17
+
18
+ * No changes.
19
+
20
+
21
+ ## Rails 7.1.4.2 (October 23, 2024) ##
22
+
23
+ * Fix NoMethodError in `block_format` helper
24
+
25
+ *Michael Leimstaedtner*
26
+
27
+
28
+ ## Rails 7.1.4.1 (October 15, 2024) ##
29
+
30
+ * Avoid regex backtracking in `block_format` helper
31
+
32
+ [CVE-2024-47889]
33
+
34
+ *John Hawthorn*
35
+
36
+
37
+ ## Rails 7.1.4 (August 22, 2024) ##
38
+
39
+ * No changes.
40
+
41
+
42
+ ## Rails 7.1.3.4 (June 04, 2024) ##
43
+
44
+ * No changes.
45
+
46
+
47
+ ## Rails 7.1.3.3 (May 16, 2024) ##
48
+
49
+ * No changes.
50
+
51
+
52
+ ## Rails 7.1.3.2 (February 21, 2024) ##
53
+
54
+ * No changes.
55
+
56
+
57
+ ## Rails 7.1.3.1 (February 21, 2024) ##
58
+
59
+ * No changes.
60
+
61
+
62
+ ## Rails 7.1.3 (January 16, 2024) ##
63
+
64
+ * No changes.
65
+
66
+
67
+ ## Rails 7.1.2 (November 10, 2023) ##
68
+
69
+ * No changes.
70
+
71
+
72
+ ## Rails 7.1.1 (October 11, 2023) ##
73
+
74
+ * No changes.
75
+
76
+
77
+ ## Rails 7.1.0 (October 05, 2023) ##
78
+
79
+ * No changes.
80
+
81
+
82
+ ## Rails 7.1.0.rc2 (October 01, 2023) ##
83
+
84
+ * No changes.
85
+
86
+
87
+ ## Rails 7.1.0.rc1 (September 27, 2023) ##
88
+
89
+ * Introduce `ActionMailer::FormBuilder`
90
+
91
+ Use the `default_form_builder` method in mailers to set the default form builder
92
+ for templates rendered by that mailer. Matches the behaviour in Action Controller.
93
+
94
+ *Alex Ghiculescu*
95
+
96
+
97
+ ## Rails 7.1.0.beta1 (September 13, 2023) ##
98
+
99
+ * Mailers are listed in alphabetical order on the mailer preview page now.
100
+
101
+ *Martin Spickermann*
102
+
103
+ * Deprecate passing params to `assert_enqueued_email_with` via the `:args`
104
+ kwarg. `assert_enqueued_email_with` now supports a `:params` kwarg, so use
105
+ that to pass params:
106
+
107
+ ```ruby
108
+ # BEFORE
109
+ assert_enqueued_email_with MyMailer, :my_method, args: { my_param: "value" }
110
+
111
+ # AFTER
112
+ assert_enqueued_email_with MyMailer, :my_method, params: { my_param: "value" }
113
+ ```
114
+
115
+ To specify named mailer args as a Hash, wrap the Hash in an array:
116
+
117
+ ```ruby
118
+ assert_enqueued_email_with MyMailer, :my_method, args: [{ my_arg: "value" }]
119
+ # OR
120
+ assert_enqueued_email_with MyMailer, :my_method, args: [my_arg: "value"]
121
+ ```
122
+
123
+ *Jonathan Hefner*
124
+
125
+ * Accept procs for args and params in `assert_enqueued_email_with`
126
+
127
+ ```ruby
128
+ assert_enqueued_email_with DeliveryJob, params: -> p { p[:token] =~ /\w+/ } do
129
+ UserMailer.with(token: user.generate_token).email_verification.deliver_later
130
+ end
131
+ ```
132
+
133
+ *Max Chernyak*
134
+
135
+ * Added `*_deliver` callbacks to `ActionMailer::Base` that wrap mail message delivery.
136
+
137
+ Example:
138
+
139
+ ```ruby
140
+ class EventsMailer < ApplicationMailer
141
+ after_deliver do
142
+ User.find_by(email: message.to.first).update(email_provider_id: message.message_id, emailed_at: Time.current)
143
+ end
144
+ end
145
+ ```
146
+
147
+ *Ben Sheldon*
148
+
149
+ * Added `deliver_enqueued_emails` to `ActionMailer::TestHelper`. This method
150
+ delivers all enqueued email jobs.
151
+
152
+ Example:
153
+
154
+ ```ruby
155
+ def test_deliver_enqueued_emails
156
+ deliver_enqueued_emails do
157
+ ContactMailer.welcome.deliver_later
158
+ end
159
+ assert_emails 1
160
+ end
161
+ ```
162
+
163
+ *Andrew Novoselac*
164
+
165
+ * The `deliver_later_queue_name` used by the default mailer job can now be
166
+ configured on a per-mailer basis. Previously this was only configurable
167
+ for all mailers via `ActionMailer::Base`.
168
+
169
+ Example:
170
+
171
+ ```ruby
172
+ class EventsMailer < ApplicationMailer
173
+ self.deliver_later_queue_name = :throttled_mailer
174
+ end
175
+ ```
176
+
177
+ *Jeffrey Hardy*
178
+
179
+ * Email previews now include an expandable section to show all headers.
180
+
181
+ Headers like `Message-ID` for threading or email service provider specific
182
+ features like analytics tags or account metadata can now be viewed directly
183
+ in the mailer preview.
184
+
185
+ *Matt Swanson*
186
+
187
+ * Default `ActionMailer::Parameterized#params` to an empty `Hash`
188
+
189
+ *Sean Doyle*
190
+
191
+ * Introduce the `capture_emails` test helper.
192
+
193
+ Returns all emails that are sent in a block.
194
+
195
+ ```ruby
196
+ def test_emails
197
+ emails = capture_emails do
198
+ ContactMailer.welcome.deliver_now
199
+ ContactMailer.welcome.deliver_later
200
+ end
201
+ assert_email "Hi there", emails.first.subject
202
+ end
203
+ ```
204
+
205
+ *Alex Ghiculescu*
206
+
207
+ * Added ability to download `.eml` file for the email preview.
208
+
209
+ *Igor Kasyanchuk*
210
+
211
+ * Support multiple preview paths for mailers.
212
+
213
+ Option `config.action_mailer.preview_path` is deprecated in favor of
214
+ `config.action_mailer.preview_paths`. Appending paths to this configuration option
215
+ will cause those paths to be used in the search for mailer previews.
216
+
217
+ *fatkodima*
218
+
219
+ Please check [7-0-stable](https://github.com/rails/rails/blob/7-0-stable/actionmailer/CHANGELOG.md) for previous changes.
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2004-2010 David Heinemeier Hansson
1
+ Copyright (c) David Heinemeier Hansson
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = Action Mailer -- Easy email delivery and testing
2
2
 
3
- Action Mailer is a framework for designing email-service layers. These layers
3
+ Action Mailer is a framework for designing email service layers. These layers
4
4
  are used to consolidate code for sending out forgotten passwords, welcome
5
5
  wishes on signup, invoices for billing, and any other use case that requires
6
6
  a written notification to either a person or another system.
@@ -10,9 +10,11 @@ Mail gem. It provides a way to make emails using templates in the same
10
10
  way that Action Controller renders views using templates.
11
11
 
12
12
  Additionally, an Action Mailer class can be used to process incoming email,
13
- such as allowing a weblog to accept new posts from an email (which could even
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://guides.rubyonrails.org/action_mailer_basics.html] guide.
17
+
16
18
  == Sending emails
17
19
 
18
20
  The framework works by initializing any instance variables you want to be
@@ -22,17 +24,17 @@ the email.
22
24
  This can be as simple as:
23
25
 
24
26
  class Notifier < ActionMailer::Base
25
- delivers_from 'system@loudthinking.com'
27
+ default from: 'system@loudthinking.com'
26
28
 
27
29
  def welcome(recipient)
28
30
  @recipient = recipient
29
- mail(:to => recipient,
30
- :subject => "[Signed up] Welcome #{recipient}")
31
+ mail(to: recipient,
32
+ subject: "[Signed up] Welcome #{recipient}")
31
33
  end
32
34
  end
33
35
 
34
36
  The body of the email is created by using an Action View template (regular
35
- ERb) that has the instance variables that are declared in the mailer action.
37
+ ERB) that has the instance variables that are declared in the mailer action.
36
38
 
37
39
  So the corresponding body template for the method above could look like this:
38
40
 
@@ -42,7 +44,7 @@ So the corresponding body template for the method above could look like this:
42
44
 
43
45
  Thank you for signing up!
44
46
 
45
- And if the recipient was given as "david@loudthinking.com", the email
47
+ If the recipient was given as "david@loudthinking.com", the email
46
48
  generated would look like this:
47
49
 
48
50
  Date: Mon, 25 Jan 2010 22:48:09 +1100
@@ -59,89 +61,81 @@ generated would look like this:
59
61
 
60
62
  Mr. david@loudthinking.com
61
63
 
62
- In previous version of rails you would call <tt>create_method_name</tt> and
63
- <tt>deliver_method_name</tt>. Rails 3.0 has a much simpler interface, you
64
- simply call the method and optionally call +deliver+ on the return value.
64
+ Thank you for signing up!
65
+
66
+ In order to send mails, you simply call the method and then call +deliver_now+ on the return value.
65
67
 
66
68
  Calling the method returns a Mail Message object:
67
69
 
68
- message = Notifier.welcome # => Returns a Mail::Message object
69
- message.deliver # => delivers the email
70
+ message = Notifier.welcome("david@loudthinking.com") # => Returns a Mail::Message object
71
+ message.deliver_now # => delivers the email
70
72
 
71
73
  Or you can just chain the methods together like:
72
74
 
73
- Notifier.welcome.deliver # Creates the email and sends it immediately
75
+ Notifier.welcome("david@loudthinking.com").deliver_now # Creates the email and sends it immediately
74
76
 
75
- == Receiving emails
77
+ == Setting defaults
76
78
 
77
- To receive emails, you need to implement a public instance method called <tt>receive</tt> that takes a
78
- tmail object as its single parameter. The Action Mailer framework has a corresponding class method,
79
- which is also called <tt>receive</tt>, that accepts a raw, unprocessed email as a string, which it then turns
80
- into the tmail object and calls the receive instance method.
79
+ It is possible to set default values that will be used in every method in your
80
+ Action Mailer class. To implement this functionality, you just call the public
81
+ class method +default+ which you get for free from ActionMailer::Base.
82
+ This method accepts a Hash as the parameter. You can use any of the headers,
83
+ email messages have, like +:from+ as the key. You can also pass in a string as
84
+ the key, like "Content-Type", but Action Mailer does this out of the box for you,
85
+ so you won't need to worry about that. Finally, it is also possible to pass in a
86
+ Proc that will get evaluated when it is needed.
87
+
88
+ Note that every value you set with this method will get overwritten if you use the
89
+ same key in your mailer method.
81
90
 
82
91
  Example:
83
92
 
84
- class Mailman < ActionMailer::Base
85
- def receive(email)
86
- page = Page.find_by_address(email.to.first)
87
- page.emails.create(
88
- :subject => email.subject, :body => email.body
89
- )
90
-
91
- if email.has_attachments?
92
- for attachment in email.attachments
93
- page.attachments.create({
94
- :file => attachment, :description => email.subject
95
- })
96
- end
97
- end
98
- end
93
+ class AuthenticationMailer < ActionMailer::Base
94
+ default from: "awesome@application.com", subject: Proc.new { "E-mail was generated at #{Time.now}" }
95
+ .....
99
96
  end
100
97
 
101
- This Mailman can be the target for Postfix or other MTAs. In Rails, you would use the runner in the
102
- trivial case like this:
103
-
104
- rails runner 'Mailman.receive(STDIN.read)'
105
-
106
- However, invoking Rails in the runner for each mail to be received is very resource intensive. A single
107
- instance of Rails should be run within a daemon if it is going to be utilized to process more than just
108
- a limited number of email.
109
-
110
98
  == Configuration
111
99
 
112
100
  The Base class has the full list of configuration options. Here's an example:
113
101
 
114
102
  ActionMailer::Base.smtp_settings = {
115
- :address => 'smtp.yourserver.com', # default: localhost
116
- :port => '25', # default: 25
117
- :user_name => 'user',
118
- :password => 'pass',
119
- :authentication => :plain # :plain, :login or :cram_md5
103
+ address: 'smtp.yourserver.com', # default: localhost
104
+ port: '25', # default: 25
105
+ user_name: 'user',
106
+ password: 'pass',
107
+ authentication: :plain # :plain, :login or :cram_md5
120
108
  }
121
109
 
122
110
 
123
111
  == Download and installation
124
112
 
125
- The latest version of Action Mailer can be installed with Rubygems:
113
+ The latest version of Action Mailer can be installed with RubyGems:
126
114
 
127
- % [sudo] gem install actionmailer
115
+ $ gem install actionmailer
128
116
 
129
- Source code can be downloaded as part of the Rails project on GitHub
117
+ Source code can be downloaded as part of the \Rails project on GitHub:
130
118
 
131
- * http://github.com/rails/rails/tree/master/actionmailer/
119
+ * https://github.com/rails/rails/tree/main/actionmailer
132
120
 
133
121
 
134
122
  == License
135
123
 
136
- Action Mailer is released under the MIT license.
124
+ Action Mailer is released under the MIT license:
125
+
126
+ * https://opensource.org/licenses/MIT
137
127
 
138
128
 
139
129
  == Support
140
130
 
141
131
  API documentation is at
142
132
 
143
- * http://api.rubyonrails.com
133
+ * https://api.rubyonrails.org
134
+
135
+ Bug reports for the Ruby on \Rails project can be filed here:
136
+
137
+ * https://github.com/rails/rails/issues
144
138
 
145
- Bug reports and feature requests can be filed with the rest for the Ruby on Rails project here:
139
+ Feature requests should be discussed on the rails-core mailing list here:
146
140
 
147
- * https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets
141
+ * https://discuss.rubyonrails.org/c/rubyonrails-core