omg-actionmailer 8.0.0.alpha2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +2 -0
- data/MIT-LICENSE +21 -0
- data/README.rdoc +141 -0
- data/lib/action_mailer/base.rb +1076 -0
- data/lib/action_mailer/callbacks.rb +31 -0
- data/lib/action_mailer/collector.rb +32 -0
- data/lib/action_mailer/delivery_methods.rb +83 -0
- 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 +44 -0
- data/lib/action_mailer/mail_delivery_job.rb +48 -0
- data/lib/action_mailer/mail_helper.rb +74 -0
- data/lib/action_mailer/message_delivery.rb +156 -0
- data/lib/action_mailer/parameterized.rb +154 -0
- data/lib/action_mailer/preview.rb +142 -0
- data/lib/action_mailer/queued_delivery.rb +12 -0
- data/lib/action_mailer/railtie.rb +94 -0
- data/lib/action_mailer/rescuable.rb +33 -0
- data/lib/action_mailer/test_case.rb +126 -0
- data/lib/action_mailer/test_helper.rb +264 -0
- data/lib/action_mailer/version.rb +11 -0
- data/lib/action_mailer.rb +79 -0
- data/lib/rails/generators/mailer/USAGE +20 -0
- data/lib/rails/generators/mailer/mailer_generator.rb +38 -0
- data/lib/rails/generators/mailer/templates/application_mailer.rb.tt +6 -0
- data/lib/rails/generators/mailer/templates/mailer.rb.tt +19 -0
- metadata +162 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4475f95642e5b514c592c4a1962d62e09aaf1786a1ffbe1f7056312505803516
|
4
|
+
data.tar.gz: b01726b9047d1bcf4409a53151469b0f2a0e66f2b993b2805febc748c3d5bfe0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c874509480421437bb9e24bbf2e6b7c1bc14d2de9eda9bd8730368cb1d6f5680d905f3a8754fb36dcb7ee7dd86cf1fee5ddb34db36b5a46bf8c5b551dbe58a4e
|
7
|
+
data.tar.gz: 7052f1de25c58b0bbe7178459c68d8964af7c3828377c345d1be4cf7df5e7bf9c7cf70e09bf6ee120ac9abfe59a45307c4073f700570f8f47483212f7e481150
|
data/CHANGELOG.md
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Copyright (c) David Heinemeier Hansson
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
data/README.rdoc
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
= Action Mailer -- Easy email delivery and testing
|
2
|
+
|
3
|
+
Action Mailer is a framework for designing email service layers. These layers
|
4
|
+
are used to consolidate code for sending out forgotten passwords, welcome
|
5
|
+
wishes on signup, invoices for billing, and any other use case that requires
|
6
|
+
a written notification to either a person or another system.
|
7
|
+
|
8
|
+
Action Mailer is in essence a wrapper around Action Controller and the
|
9
|
+
Mail gem. It provides a way to make emails using templates in the same
|
10
|
+
way that Action Controller renders views using templates.
|
11
|
+
|
12
|
+
Additionally, an Action Mailer class can be used to process incoming email,
|
13
|
+
such as allowing a blog to accept new posts from an email (which could even
|
14
|
+
have been sent from a phone).
|
15
|
+
|
16
|
+
You can read more about Action Mailer in the {Action Mailer Basics}[https://guides.rubyonrails.org/action_mailer_basics.html] guide.
|
17
|
+
|
18
|
+
== Sending emails
|
19
|
+
|
20
|
+
The framework works by initializing any instance variables you want to be
|
21
|
+
available in the email template, followed by a call to +mail+ to deliver
|
22
|
+
the email.
|
23
|
+
|
24
|
+
This can be as simple as:
|
25
|
+
|
26
|
+
class Notifier < ActionMailer::Base
|
27
|
+
default from: 'system@loudthinking.com'
|
28
|
+
|
29
|
+
def welcome(recipient)
|
30
|
+
@recipient = recipient
|
31
|
+
mail(to: recipient,
|
32
|
+
subject: "[Signed up] Welcome #{recipient}")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
The body of the email is created by using an Action View template (regular
|
37
|
+
ERB) that has the instance variables that are declared in the mailer action.
|
38
|
+
|
39
|
+
So the corresponding body template for the method above could look like this:
|
40
|
+
|
41
|
+
Hello there,
|
42
|
+
|
43
|
+
Mr. <%= @recipient %>
|
44
|
+
|
45
|
+
Thank you for signing up!
|
46
|
+
|
47
|
+
If the recipient was given as "david@loudthinking.com", the email
|
48
|
+
generated would look like this:
|
49
|
+
|
50
|
+
Date: Mon, 25 Jan 2010 22:48:09 +1100
|
51
|
+
From: system@loudthinking.com
|
52
|
+
To: david@loudthinking.com
|
53
|
+
Message-ID: <4b5d84f9dd6a5_7380800b81ac29578@void.loudthinking.com.mail>
|
54
|
+
Subject: [Signed up] Welcome david@loudthinking.com
|
55
|
+
Mime-Version: 1.0
|
56
|
+
Content-Type: text/plain;
|
57
|
+
charset="US-ASCII";
|
58
|
+
Content-Transfer-Encoding: 7bit
|
59
|
+
|
60
|
+
Hello there,
|
61
|
+
|
62
|
+
Mr. david@loudthinking.com
|
63
|
+
|
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.
|
67
|
+
|
68
|
+
Calling the method returns a Mail Message object:
|
69
|
+
|
70
|
+
message = Notifier.welcome("david@loudthinking.com") # => Returns a Mail::Message object
|
71
|
+
message.deliver_now # => delivers the email
|
72
|
+
|
73
|
+
Or you can just chain the methods together like:
|
74
|
+
|
75
|
+
Notifier.welcome("david@loudthinking.com").deliver_now # Creates the email and sends it immediately
|
76
|
+
|
77
|
+
== Setting defaults
|
78
|
+
|
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.
|
90
|
+
|
91
|
+
Example:
|
92
|
+
|
93
|
+
class AuthenticationMailer < ActionMailer::Base
|
94
|
+
default from: "awesome@application.com", subject: Proc.new { "E-mail was generated at #{Time.now}" }
|
95
|
+
.....
|
96
|
+
end
|
97
|
+
|
98
|
+
== Configuration
|
99
|
+
|
100
|
+
The Base class has the full list of configuration options. Here's an example:
|
101
|
+
|
102
|
+
ActionMailer::Base.smtp_settings = {
|
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
|
108
|
+
}
|
109
|
+
|
110
|
+
|
111
|
+
== Download and installation
|
112
|
+
|
113
|
+
The latest version of Action Mailer can be installed with RubyGems:
|
114
|
+
|
115
|
+
$ gem install actionmailer
|
116
|
+
|
117
|
+
Source code can be downloaded as part of the \Rails project on GitHub:
|
118
|
+
|
119
|
+
* https://github.com/rails/rails/tree/main/actionmailer
|
120
|
+
|
121
|
+
|
122
|
+
== License
|
123
|
+
|
124
|
+
Action Mailer is released under the MIT license:
|
125
|
+
|
126
|
+
* https://opensource.org/licenses/MIT
|
127
|
+
|
128
|
+
|
129
|
+
== Support
|
130
|
+
|
131
|
+
API documentation is at
|
132
|
+
|
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
|
138
|
+
|
139
|
+
Feature requests should be discussed on the rails-core mailing list here:
|
140
|
+
|
141
|
+
* https://discuss.rubyonrails.org/c/rubyonrails-core
|