Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 793 lines (744 sloc) 33.972 kb
616ebb8 José Valim Remove unused code paths and require mail only when it's needed.
josevalim authored
1 require 'mail'
c985a0e Add some tests to collector with templates and any.
José Valim and Mikel Lindsaar authored
2 require 'action_mailer/collector'
76f024a Xavier Noria adds missing requires for Object#blank? and Object#present?
fxn authored
3 require 'active_support/core_ext/object/blank'
284ca81 Josh Kalderimis remove AM delegating register_observer and register_interceptor to Mail ...
joshk authored
4 require 'active_support/core_ext/string/inflections'
0f8a6eb Prem Sichanugrist Fix missing requires in Action Mailer
sikachu authored
5 require 'active_support/core_ext/hash/except'
c17d200 Sergey Nartimov mailer can be anonymous
lest authored
6 require 'active_support/core_ext/module/anonymous'
6788db8 José Valim Move Rails::LogSubscriber to ActiveSupport::LogSubscriber, allowing fram...
josevalim authored
7 require 'action_mailer/log_subscriber'
a63caa4 Get tests to run (with failures) without old base around
Yehuda Katz + Carl Lerche authored
8
c4590d5 David Heinemeier Hansson Fixed docs
dhh authored
9 module ActionMailer #:nodoc:
98dc582 Pratik Merge docrails.
lifo authored
10 # Action Mailer allows you to send email from your application using a mailer model and views.
db045db David Heinemeier Hansson Initial
dhh authored
11 #
0a407bc ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, Mar...
Marcel Molina authored
12 # = Mailer Models
20bd4bd David Heinemeier Hansson Updated docs and otherwise
dhh authored
13 #
98dc582 Pratik Merge docrails.
lifo authored
14 # To use Action Mailer, you need to create a mailer model.
3b0e1d9 Joshua Peek Prefer string core_ext inflector methods over directly accessing Inflect...
josh authored
15 #
f44a0b1 Roman Dittert fix usage examples and more to use new invocations
romdi authored
16 # $ rails generate mailer Notifier
0a407bc ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, Mar...
Marcel Molina authored
17 #
c291195 Charles Brian Quinn Updates ActionMailer Base summary and fixes space in code example.
seebq authored
18 # The generated model inherits from <tt>ActionMailer::Base</tt>. A mailer model defines methods
19 # used to generate an email message. In these methods, you can setup variables to be used in
20 # the mailer views, options on the mail itself such as the <tt>:from</tt> address, and attachments.
0a407bc ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, Mar...
Marcel Molina authored
21 #
22 # Examples:
23 #
0f0213f Siong minor spacing fix in code example in ActionMailer::Base.
siong1987 authored
24 # class Notifier < ActionMailer::Base
25 # default :from => 'no-reply@example.com',
c291195 Charles Brian Quinn Updates ActionMailer Base summary and fixes space in code example.
seebq authored
26 # :return_path => 'system@example.com'
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
27 #
0f0213f Siong minor spacing fix in code example in ActionMailer::Base.
siong1987 authored
28 # def welcome(recipient)
29 # @account = recipient
30 # mail(:to => recipient.email_address_with_name,
31 # :bcc => ["bcc@example.com", "Order Watcher <watcher@example.com>"])
32 # end
33 # end
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
34 #
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
35 # Within the mailer method, you have access to the following methods:
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
36 #
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
37 # * <tt>attachments[]=</tt> - Allows you to add attachments to your email in an intuitive
38 # manner; <tt>attachments['filename.png'] = File.read('path/to/filename.png')</tt>
6589976 Remove old files, add some information to docs and improve test suite.
José Valim and Mikel Lindsaar authored
39 #
3762362 Mikel Lindsaar Updating readme for ActionMailer::Base
mikel authored
40 # * <tt>attachments.inline[]=</tt> - Allows you to add an inline attachment to your email
41 # in the same manner as <tt>attachments[]=</tt>
42 #
bb2c7b4 Mikel Lindsaar Updating Action Mailer documentation
mikel authored
43 # * <tt>headers[]=</tt> - Allows you to specify any header field in your email such
daad445 Neeraj Singh itsy bitsy changes to ActionMailer documentation
neerajdotname authored
44 # as <tt>headers['X-No-Spam'] = 'True'</tt>. Note, while most fields like <tt>To:</tt>
bb2c7b4 Mikel Lindsaar Updating Action Mailer documentation
mikel authored
45 # <tt>From:</tt> can only appear once in an email header, other fields like <tt>X-Anything</tt>
46 # can appear multiple times. If you want to change a field that can appear multiple times,
daad445 Neeraj Singh itsy bitsy changes to ActionMailer documentation
neerajdotname authored
47 # you need to set it to nil first so that Mail knows you are replacing it and not adding
48 # another field of the same name.
6589976 Remove old files, add some information to docs and improve test suite.
José Valim and Mikel Lindsaar authored
49 #
9520166 Mikel Lindsaar Fixed up being able to pass random headers in with headers, or mail. Al...
mikel authored
50 # * <tt>headers(hash)</tt> - Allows you to specify multiple headers in your email such
51 # as <tt>headers({'X-No-Spam' => 'True', 'In-Reply-To' => '1234@message.id'})</tt>
52 #
daad445 Neeraj Singh itsy bitsy changes to ActionMailer documentation
neerajdotname authored
53 # * <tt>mail</tt> - Allows you to specify email to be sent.
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
54 #
9520166 Mikel Lindsaar Fixed up being able to pass random headers in with headers, or mail. Al...
mikel authored
55 # The hash passed to the mail method allows you to specify any header that a Mail::Message
bb2c7b4 Mikel Lindsaar Updating Action Mailer documentation
mikel authored
56 # will accept (any valid Email header including optional fields).
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
57 #
58 # The mail method, if not passed a block, will inspect your views and send all the views with
b62c549 Jason Fox The name for the plain text template in Rails3 appears to be method.text...
jasonfox authored
59 # the same name as the method, so the above action would send the +welcome.text.erb+ view
bb2c7b4 Mikel Lindsaar Updating Action Mailer documentation
mikel authored
60 # file as well as the +welcome.text.html.erb+ view file in a +multipart/alternative+ email.
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
61 #
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
62 # If you want to explicitly render only certain templates, pass a block:
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
63 #
c125116 David Chelimsky docfix (email instead of emai)
dchelimsky authored
64 # mail(:to => user.email) do |format|
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
65 # format.text
66 # format.html
67 # end
20bd4bd David Heinemeier Hansson Updated docs and otherwise
dhh authored
68 #
daad445 Neeraj Singh itsy bitsy changes to ActionMailer documentation
neerajdotname authored
69 # The block syntax is also useful in providing information specific to a part:
6589976 Remove old files, add some information to docs and improve test suite.
José Valim and Mikel Lindsaar authored
70 #
c125116 David Chelimsky docfix (email instead of emai)
dchelimsky authored
71 # mail(:to => user.email) do |format|
6589976 Remove old files, add some information to docs and improve test suite.
José Valim and Mikel Lindsaar authored
72 # format.text(:content_transfer_encoding => "base64")
73 # format.html
74 # end
75 #
bb2c7b4 Mikel Lindsaar Updating Action Mailer documentation
mikel authored
76 # Or even to render a special view:
6589976 Remove old files, add some information to docs and improve test suite.
José Valim and Mikel Lindsaar authored
77 #
c125116 David Chelimsky docfix (email instead of emai)
dchelimsky authored
78 # mail(:to => user.email) do |format|
6589976 Remove old files, add some information to docs and improve test suite.
José Valim and Mikel Lindsaar authored
79 # format.text
80 # format.html { render "some_other_template" }
81 # end
82 #
20bd4bd David Heinemeier Hansson Updated docs and otherwise
dhh authored
83 # = Mailer views
84 #
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
85 # Like Action Controller, each mailer class has a corresponding view directory in which each
86 # method of the class looks for a template with its name.
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
87 #
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
88 # To define a template to be used with a mailing, create an <tt>.erb</tt> file with the same
89 # name as the method in your mailer model. For example, in the mailer defined above, the template at
b62c549 Jason Fox The name for the plain text template in Rails3 appears to be method.text...
jasonfox authored
90 # <tt>app/views/notifier/welcome.text.erb</tt> would be used to generate the email.
0a407bc ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, Mar...
Marcel Molina authored
91 #
92 # Variables defined in the model are accessible as instance variables in the view.
93 #
94 # Emails by default are sent in plain text, so a sample view for our model example might look like this:
95 #
96 # Hi <%= @account.name %>,
97 # Thanks for joining our service! Please check back often.
98 #
20bd4bd David Heinemeier Hansson Updated docs and otherwise
dhh authored
99 # You can even use Action Pack helpers in these views. For example:
100 #
101 # You got a new note!
80f1d40 Alexey Vakhov update ActionMailer example using last truncate helper method signature
avakhov authored
102 # <%= truncate(@note.body, :length => 25) %>
ee70d1b José Valim adv_attr_accessors in ActionMailer are not sent to the views, use the ma...
josevalim authored
103 #
6589976 Remove old files, add some information to docs and improve test suite.
José Valim and Mikel Lindsaar authored
104 # If you need to access the subject, from or the recipients in the view, you can do that through message object:
ee70d1b José Valim adv_attr_accessors in ActionMailer are not sent to the views, use the ma...
josevalim authored
105 #
6589976 Remove old files, add some information to docs and improve test suite.
José Valim and Mikel Lindsaar authored
106 # You got a new note from <%= message.from %>!
80f1d40 Alexey Vakhov update ActionMailer example using last truncate helper method signature
avakhov authored
107 # <%= truncate(@note.body, :length => 25) %>
3b0e1d9 Joshua Peek Prefer string core_ext inflector methods over directly accessing Inflect...
josh authored
108 #
20bd4bd David Heinemeier Hansson Updated docs and otherwise
dhh authored
109 #
4809dcc * Remove default_url_options from mailer generator
Cody Fauser authored
110 # = Generating URLs
3b0e1d9 Joshua Peek Prefer string core_ext inflector methods over directly accessing Inflect...
josh authored
111 #
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
112 # URLs can be generated in mailer views using <tt>url_for</tt> or named routes. Unlike controllers from
bb2c7b4 Mikel Lindsaar Updating Action Mailer documentation
mikel authored
113 # Action Pack, the mailer instance doesn't have any context about the incoming request, so you'll need
114 # to provide all of the details needed to generate a URL.
20bd4bd David Heinemeier Hansson Updated docs and otherwise
dhh authored
115 #
4809dcc * Remove default_url_options from mailer generator
Cody Fauser authored
116 # When using <tt>url_for</tt> you'll need to provide the <tt>:host</tt>, <tt>:controller</tt>, and <tt>:action</tt>:
3b0e1d9 Joshua Peek Prefer string core_ext inflector methods over directly accessing Inflect...
josh authored
117 #
4809dcc * Remove default_url_options from mailer generator
Cody Fauser authored
118 # <%= url_for(:host => "example.com", :controller => "welcome", :action => "greeting") %>
20bd4bd David Heinemeier Hansson Updated docs and otherwise
dhh authored
119 #
4809dcc * Remove default_url_options from mailer generator
Cody Fauser authored
120 # When using named routes you only need to supply the <tt>:host</tt>:
3b0e1d9 Joshua Peek Prefer string core_ext inflector methods over directly accessing Inflect...
josh authored
121 #
4809dcc * Remove default_url_options from mailer generator
Cody Fauser authored
122 # <%= users_url(:host => "example.com") %>
123 #
3438f6c Rafael Mendonça França Array.wrap is no longer needed here
rafaelfranca authored
124 # You should use the <tt>named_route_url</tt> style (which generates absolute URLs) and avoid using the
125 # <tt>named_route_path</tt> style (which generates relative URLs), since clients reading the mail will
1f4fb6f Matt Jankowski elaborate details on why to use _url instead of _path in mailers
mjankowski authored
126 # have no concept of a current URL from which to determine a relative path.
4809dcc * Remove default_url_options from mailer generator
Cody Fauser authored
127 #
bb2c7b4 Mikel Lindsaar Updating Action Mailer documentation
mikel authored
128 # It is also possible to set a default host that will be used in all mailers by setting the <tt>:host</tt>
ab62aa1 Jeroen van Dijk Mention that ActionMailer::Base.default_url_options is now deprecated
jeroenvandijk authored
129 # option as a configuration option in <tt>config/application.rb</tt>:
4809dcc * Remove default_url_options from mailer generator
Cody Fauser authored
130 #
131 # config.action_mailer.default_url_options = { :host => "example.com" }
20bd4bd David Heinemeier Hansson Updated docs and otherwise
dhh authored
132 #
4f433bc Matt Jankowski clarify why the only_path => false option is needed when default :host h...
mjankowski authored
133 # When you decide to set a default <tt>:host</tt> for your mailers, then you need to make sure to use the
3438f6c Rafael Mendonça França Array.wrap is no longer needed here
rafaelfranca authored
134 # <tt>:only_path => false</tt> option when using <tt>url_for</tt>. Since the <tt>url_for</tt> view helper
4f433bc Matt Jankowski clarify why the only_path => false option is needed when default :host h...
mjankowski authored
135 # will generate relative URLs by default when a <tt>:host</tt> option isn't explicitly provided, passing
136 # <tt>:only_path => false</tt> will ensure that absolute URLs are generated.
20bd4bd David Heinemeier Hansson Updated docs and otherwise
dhh authored
137 #
138 # = Sending mail
139 #
3b0e1d9 Joshua Peek Prefer string core_ext inflector methods over directly accessing Inflect...
josh authored
140 # Once a mailer action and template are defined, you can deliver your message or create it and save it
0a407bc ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, Mar...
Marcel Molina authored
141 # for delivery later:
142 #
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
143 # Notifier.welcome(david).deliver # sends the email
144 # mail = Notifier.welcome(david) # => a Mail::Message object
145 # mail.deliver # sends the email
0a407bc ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, Mar...
Marcel Molina authored
146 #
bb2c7b4 Mikel Lindsaar Updating Action Mailer documentation
mikel authored
147 # You never instantiate your mailer class. Rather, you just call the method you defined on the class itself.
20bd4bd David Heinemeier Hansson Updated docs and otherwise
dhh authored
148 #
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
149 # = Multipart Emails
3b0e1d9 Joshua Peek Prefer string core_ext inflector methods over directly accessing Inflect...
josh authored
150 #
3438f6c Rafael Mendonça França Array.wrap is no longer needed here
rafaelfranca authored
151 # Multipart messages can also be used implicitly because Action Mailer will automatically detect and use
152 # multipart templates, where each template is named after the name of the action, followed by the content
f3db04f Matt Jankowski grammar (missing "a") and formatting
mjankowski authored
153 # type. Each such detected template will be added as a separate part to the message.
3b0e1d9 Joshua Peek Prefer string core_ext inflector methods over directly accessing Inflect...
josh authored
154 #
daad445 Neeraj Singh itsy bitsy changes to ActionMailer documentation
neerajdotname authored
155 # For example, if the following templates exist:
b62c549 Jason Fox The name for the plain text template in Rails3 appears to be method.text...
jasonfox authored
156 # * signup_notification.text.erb
21187c0 David Heinemeier Hansson Apply the rest of Chads patch
dhh authored
157 # * signup_notification.text.html.erb
158 # * signup_notification.text.xml.builder
6589976 Remove old files, add some information to docs and improve test suite.
José Valim and Mikel Lindsaar authored
159 # * signup_notification.text.yaml.erb
3b0e1d9 Joshua Peek Prefer string core_ext inflector methods over directly accessing Inflect...
josh authored
160 #
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
161 # Each would be rendered and added as a separate part to the message, with the corresponding content
162 # type. The content type for the entire message is automatically set to <tt>multipart/alternative</tt>,
163 # which indicates that the email contains multiple different representations of the same email
164 # body. The same instance variables defined in the action are passed to all email templates.
359caef Jamis Buck A very thorough refactoring, resulting in new mail property setters and ...
jamis authored
165 #
46f30f9 Pratik Merge documentation changes from docrails.
lifo authored
166 # Implicit template rendering is not performed if any attachments or parts have been added to the email.
167 # This means that you'll have to manually add each part to the email and set the content type of the email
168 # to <tt>multipart/alternative</tt>.
20bd4bd David Heinemeier Hansson Updated docs and otherwise
dhh authored
169 #
0a407bc ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, Mar...
Marcel Molina authored
170 # = Attachments
20bd4bd David Heinemeier Hansson Updated docs and otherwise
dhh authored
171 #
daad445 Neeraj Singh itsy bitsy changes to ActionMailer documentation
neerajdotname authored
172 # Sending attachment in emails is easy:
0a407bc ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, Mar...
Marcel Molina authored
173 #
174 # class ApplicationMailer < ActionMailer::Base
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
175 # def welcome(recipient)
3762362 Mikel Lindsaar Updating readme for ActionMailer::Base
mikel authored
176 # attachments['free_book.pdf'] = File.read('path/to/file.pdf')
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
177 # mail(:to => recipient, :subject => "New account information")
db045db David Heinemeier Hansson Initial
dhh authored
178 # end
3b0e1d9 Joshua Peek Prefer string core_ext inflector methods over directly accessing Inflect...
josh authored
179 # end
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
180 #
b62c549 Jason Fox The name for the plain text template in Rails3 appears to be method.text...
jasonfox authored
181 # Which will (if it had both a <tt>welcome.text.erb</tt> and <tt>welcome.text.html.erb</tt>
ccf9577 Ev Dolzhenko Fix a bunch of minor spelling mistakes
dolzenko authored
182 # template in the view directory), send a complete <tt>multipart/mixed</tt> email with two parts,
bb2c7b4 Mikel Lindsaar Updating Action Mailer documentation
mikel authored
183 # the first part being a <tt>multipart/alternative</tt> with the text and HTML email parts inside,
184 # and the second being a <tt>application/pdf</tt> with a Base64 encoded copy of the file.pdf book
185 # with the filename +free_book.pdf+.
c927aa0 David Heinemeier Hansson Updated documentation
dhh authored
186 #
45b1045 Damien Mathieu raise an error if no implicit mailer template could be found
dmathieu authored
187 # If you need to send attachments with no content, you need to create an empty view for it,
188 # or add an empty body parameter like this:
189 #
190 # class ApplicationMailer < ActionMailer::Base
191 # def welcome(recipient)
192 # attachments['free_book.pdf'] = File.read('path/to/file.pdf')
193 # mail(:to => recipient, :subject => "New account information", :body => "")
194 # end
195 # end
196 #
3762362 Mikel Lindsaar Updating readme for ActionMailer::Base
mikel authored
197 # = Inline Attachments
b451de0 Santiago Pastorino Deletes trailing whitespaces (over text files only find * -type f -exec ...
spastorino authored
198 #
199 # You can also specify that a file should be displayed inline with other HTML. This is useful
daad445 Neeraj Singh itsy bitsy changes to ActionMailer documentation
neerajdotname authored
200 # if you want to display a corporate logo or a photo.
b451de0 Santiago Pastorino Deletes trailing whitespaces (over text files only find * -type f -exec ...
spastorino authored
201 #
3762362 Mikel Lindsaar Updating readme for ActionMailer::Base
mikel authored
202 # class ApplicationMailer < ActionMailer::Base
203 # def welcome(recipient)
204 # attachments.inline['photo.png'] = File.read('path/to/photo.png')
205 # mail(:to => recipient, :subject => "Here is what we look like")
206 # end
207 # end
b451de0 Santiago Pastorino Deletes trailing whitespaces (over text files only find * -type f -exec ...
spastorino authored
208 #
3762362 Mikel Lindsaar Updating readme for ActionMailer::Base
mikel authored
209 # And then to reference the image in the view, you create a <tt>welcome.html.erb</tt> file and
b451de0 Santiago Pastorino Deletes trailing whitespaces (over text files only find * -type f -exec ...
spastorino authored
210 # make a call to +image_tag+ passing in the attachment you want to display and then call
3762362 Mikel Lindsaar Updating readme for ActionMailer::Base
mikel authored
211 # +url+ on the attachment to get the relative content id path for the image source:
b451de0 Santiago Pastorino Deletes trailing whitespaces (over text files only find * -type f -exec ...
spastorino authored
212 #
3762362 Mikel Lindsaar Updating readme for ActionMailer::Base
mikel authored
213 # <h1>Please Don't Cringe</h1>
b451de0 Santiago Pastorino Deletes trailing whitespaces (over text files only find * -type f -exec ...
spastorino authored
214 #
3762362 Mikel Lindsaar Updating readme for ActionMailer::Base
mikel authored
215 # <%= image_tag attachments['photo.png'].url -%>
b451de0 Santiago Pastorino Deletes trailing whitespaces (over text files only find * -type f -exec ...
spastorino authored
216 #
f17159b Xavier Noria edit pass: the names of Rails components have a space, ie, "Active Recor...
fxn authored
217 # As we are using Action View's +image_tag+ method, you can pass in any other options you want:
b451de0 Santiago Pastorino Deletes trailing whitespaces (over text files only find * -type f -exec ...
spastorino authored
218 #
3762362 Mikel Lindsaar Updating readme for ActionMailer::Base
mikel authored
219 # <h1>Please Don't Cringe</h1>
b451de0 Santiago Pastorino Deletes trailing whitespaces (over text files only find * -type f -exec ...
spastorino authored
220 #
3762362 Mikel Lindsaar Updating readme for ActionMailer::Base
mikel authored
221 # <%= image_tag attachments['photo.png'].url, :alt => 'Our Photo', :class => 'photo' -%>
b451de0 Santiago Pastorino Deletes trailing whitespaces (over text files only find * -type f -exec ...
spastorino authored
222 #
cefc136 Mikel Lindsaar Adding options to register observers and interceptors through ActionMail...
mikel authored
223 # = Observing and Intercepting Mails
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
224 #
5d0d4d8 Sebastian Martinez Remove extra white spaces on ActionMailer docs.
smartinez87 authored
225 # Action Mailer provides hooks into the Mail observer and interceptor methods. These allow you to
5acf76d Paco Guzmán Add action_mailer observer and interceptors configuration options
pacoguzman authored
226 # register classes that are called during the mail delivery life cycle.
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
227 #
5acf76d Paco Guzmán Add action_mailer observer and interceptors configuration options
pacoguzman authored
228 # An observer class must implement the <tt>:delivered_email(message)</tt> method which will be
cefc136 Mikel Lindsaar Adding options to register observers and interceptors through ActionMail...
mikel authored
229 # called once for every email sent after the email has been sent.
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
230 #
5acf76d Paco Guzmán Add action_mailer observer and interceptors configuration options
pacoguzman authored
231 # An interceptor class must implement the <tt>:delivering_email(message)</tt> method which will be
cefc136 Mikel Lindsaar Adding options to register observers and interceptors through ActionMail...
mikel authored
232 # called before the email is sent, allowing you to make modifications to the email before it hits
5acf76d Paco Guzmán Add action_mailer observer and interceptors configuration options
pacoguzman authored
233 # the delivery agents. Your class should make any needed modifications directly to the passed
cefc136 Mikel Lindsaar Adding options to register observers and interceptors through ActionMail...
mikel authored
234 # in Mail::Message instance.
20bd4bd David Heinemeier Hansson Updated docs and otherwise
dhh authored
235 #
fb30feb Mikel Lindsaar Adding more docs to ActionMailer
mikel authored
236 # = Default Hash
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
237 #
058f7fe Mikel Lindsaar Cleaning up Action Mailer spelling with and without the space
mikel authored
238 # Action Mailer provides some intelligent defaults for your emails, these are usually specified in a
fb30feb Mikel Lindsaar Adding more docs to ActionMailer
mikel authored
239 # default method inside the class definition:
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
240 #
fb30feb Mikel Lindsaar Adding more docs to ActionMailer
mikel authored
241 # class Notifier < ActionMailer::Base
242 # default :sender => 'system@example.com'
243 # end
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
244 #
ad8e1ba Cheah Chu Yeow Fix missing word in ActionMailer::Base documentation.
chuyeow authored
245 # You can pass in any header value that a <tt>Mail::Message</tt> accepts. Out of the box,
246 # <tt>ActionMailer::Base</tt> sets the following:
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
247 #
fb30feb Mikel Lindsaar Adding more docs to ActionMailer
mikel authored
248 # * <tt>:mime_version => "1.0"</tt>
249 # * <tt>:charset => "UTF-8",</tt>
250 # * <tt>:content_type => "text/plain",</tt>
251 # * <tt>:parts_order => [ "text/plain", "text/enriched", "text/html" ]</tt>
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
252 #
fb30feb Mikel Lindsaar Adding more docs to ActionMailer
mikel authored
253 # <tt>parts_order</tt> and <tt>charset</tt> are not actually valid <tt>Mail::Message</tt> header fields,
058f7fe Mikel Lindsaar Cleaning up Action Mailer spelling with and without the space
mikel authored
254 # but Action Mailer translates them appropriately and sets the correct values.
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
255 #
fb30feb Mikel Lindsaar Adding more docs to ActionMailer
mikel authored
256 # As you can pass in any header, you need to either quote the header as a string, or pass it in as
b72cd29 Mikel Lindsaar Fixing spelling
mikel authored
257 # an underscored symbol, so the following will work:
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
258 #
fb30feb Mikel Lindsaar Adding more docs to ActionMailer
mikel authored
259 # class Notifier < ActionMailer::Base
260 # default 'Content-Transfer-Encoding' => '7bit',
261 # :content_description => 'This is a description'
262 # end
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
263 #
058f7fe Mikel Lindsaar Cleaning up Action Mailer spelling with and without the space
mikel authored
264 # Finally, Action Mailer also supports passing <tt>Proc</tt> objects into the default hash, so you
fb30feb Mikel Lindsaar Adding more docs to ActionMailer
mikel authored
265 # can define methods that evaluate as the message is being generated:
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
266 #
fb30feb Mikel Lindsaar Adding more docs to ActionMailer
mikel authored
267 # class Notifier < ActionMailer::Base
268 # default 'X-Special-Header' => Proc.new { my_method }
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
269 #
fb30feb Mikel Lindsaar Adding more docs to ActionMailer
mikel authored
270 # private
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
271 #
fb30feb Mikel Lindsaar Adding more docs to ActionMailer
mikel authored
272 # def my_method
273 # 'some complex call'
274 # end
275 # end
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
276 #
fb30feb Mikel Lindsaar Adding more docs to ActionMailer
mikel authored
277 # Note that the proc is evaluated right at the start of the mail message generation, so if you
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
278 # set something in the defaults using a proc, and then set the same thing inside of your
fb30feb Mikel Lindsaar Adding more docs to ActionMailer
mikel authored
279 # mailer method, it will get over written by the mailer method.
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
280 #
4f28c4f Justin S. Leitgeb Add ability to define callbacks in ActionMailer using AbstractController...
jsl authored
281 # = Callbacks
282 #
283 # You can specify callbacks using before_filter and after_filter for configuring your messages.
284 # This may be useful, for example, when you want to add default inline attachments for all
285 # messages sent out by a certain mailer class:
286 #
287 # class Notifier < ActionMailer::Base
288 # before_filter :add_inline_attachment!
289 #
290 # def welcome
291 # mail
292 # end
293 #
294 # private
295 #
296 # def add_inline_attachment!
297 # attachments.inline["footer.jpg"] = File.read('/path/to/filename.jpg')
298 # end
299 # end
300 #
301 # Callbacks in ActionMailer are implemented using AbstractController::Callbacks, so you
302 # can define and configure callbacks in the same manner that you would use callbacks in
303 # classes that inherit from ActionController::Base.
304 #
305 # Note that unless you have a specific reason to do so, you should prefer using before_filter
306 # rather than after_filter in your ActionMailer classes so that headers are parsed properly.
307 #
c927aa0 David Heinemeier Hansson Updated documentation
dhh authored
308 # = Configuration options
309 #
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
310 # These options are specified on the class level, like
e968acc Ryan Bigg Update ActionMailer documentation to not use deprecated template_root me...
radar authored
311 # <tt>ActionMailer::Base.raise_delivery_errors = true</tt>
c927aa0 David Heinemeier Hansson Updated documentation
dhh authored
312 #
fb30feb Mikel Lindsaar Adding more docs to ActionMailer
mikel authored
313 # * <tt>default</tt> - You can pass this in at a class level as well as within the class itself as
314 # per the above section.
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
315 #
c927aa0 David Heinemeier Hansson Updated documentation
dhh authored
316 # * <tt>logger</tt> - the logger is used for generating information on the mailing run if available.
317 # Can be set to nil for no logging. Compatible with both Ruby's own Logger and Log4r loggers.
318 #
64092de Xavier Noria Improve documentation coverage and markup
fxn authored
319 # * <tt>smtp_settings</tt> - Allows detailed configuration for <tt>:smtp</tt> delivery method:
bb2c7b4 Mikel Lindsaar Updating Action Mailer documentation
mikel authored
320 # * <tt>:address</tt> - Allows you to use a remote mail server. Just change it from its default
321 # "localhost" setting.
dc4eec1 Pratik Merge docrails:
lifo authored
322 # * <tt>:port</tt> - On the off chance that your mail server doesn't run on port 25, you can change it.
323 # * <tt>:domain</tt> - If you need to specify a HELO domain, you can do it here.
324 # * <tt>:user_name</tt> - If your mail server requires authentication, set the username in this setting.
325 # * <tt>:password</tt> - If your mail server requires authentication, set the password in this setting.
bb2c7b4 Mikel Lindsaar Updating Action Mailer documentation
mikel authored
326 # * <tt>:authentication</tt> - If your mail server requires authentication, you need to specify the
327 # authentication type here.
5a898e1 Explain actionamailer authentication types
Peter Baker authored
328 # This is a symbol and one of <tt>:plain</tt> (will send the password in the clear), <tt>:login</tt> (will
3457db7 Dalibor Nasevic Correct spelling for Base64 in action_mailer
dalibor authored
329 # send password Base64 encoded) or <tt>:cram_md5</tt> (combines a Challenge/Response mechanism to exchange
5a898e1 Explain actionamailer authentication types
Peter Baker authored
330 # information and a cryptographic Message Digest 5 algorithm to hash important information)
bb2c7b4 Mikel Lindsaar Updating Action Mailer documentation
mikel authored
331 # * <tt>:enable_starttls_auto</tt> - When set to true, detects if STARTTLS is enabled in your SMTP server
332 # and starts to use it.
d500ad3 Josh Kalderimis Removed deprecated ActionMailer API and related tests
joshk authored
333 # * <tt>:openssl_verify_mode</tt> - When using TLS, you can set how OpenSSL checks the certificate. This is
334 # really useful if you need to validate a self-signed and/or a wildcard certificate. You can use the name
335 # of an OpenSSL verify constant ('none', 'peer', 'client_once','fail_if_no_peer_cert') or directly the
a1639ad Florent Piteau Undocumented :openssl_verify_mode option for smtp_settings
flop authored
336 # constant (OpenSSL::SSL::VERIFY_NONE, OpenSSL::SSL::VERIFY_PEER,...).
c927aa0 David Heinemeier Hansson Updated documentation
dhh authored
337 #
46f30f9 Pratik Merge documentation changes from docrails.
lifo authored
338 # * <tt>sendmail_settings</tt> - Allows you to override options for the <tt>:sendmail</tt> delivery method.
339 # * <tt>:location</tt> - The location of the sendmail executable. Defaults to <tt>/usr/sbin/sendmail</tt>.
b72cd29 Mikel Lindsaar Fixing spelling
mikel authored
340 # * <tt>:arguments</tt> - The command line arguments. Defaults to <tt>-i -t</tt> with <tt>-f sender@address</tt>
bb2c7b4 Mikel Lindsaar Updating Action Mailer documentation
mikel authored
341 # added automatically before the message is sent.
dc4eec1 Pratik Merge docrails:
lifo authored
342 #
fbe6c3c Eric Davis Adds a :file delivery_method to save email to a file on disk
edavis10 authored
343 # * <tt>file_settings</tt> - Allows you to override options for the <tt>:file</tt> delivery method.
bb2c7b4 Mikel Lindsaar Updating Action Mailer documentation
mikel authored
344 # * <tt>:location</tt> - The directory into which emails will be written. Defaults to the application
345 # <tt>tmp/mails</tt>.
fbe6c3c Eric Davis Adds a :file delivery_method to save email to a file on disk
edavis10 authored
346 #
dc4eec1 Pratik Merge docrails:
lifo authored
347 # * <tt>raise_delivery_errors</tt> - Whether or not errors should be raised if the email fails to be delivered.
c927aa0 David Heinemeier Hansson Updated documentation
dhh authored
348 #
bb2c7b4 Mikel Lindsaar Updating Action Mailer documentation
mikel authored
349 # * <tt>delivery_method</tt> - Defines a delivery method. Possible values are <tt>:smtp</tt> (default),
350 # <tt>:sendmail</tt>, <tt>:test</tt>, and <tt>:file</tt>. Or you may provide a custom delivery method
a4726d3 Damien Mathieu just specify what's to be done, not what's not to be.
dmathieu authored
351 # object e.g. MyOwnDeliveryMethodClass. See the Mail gem documentation on the interface you need to
bb2c7b4 Mikel Lindsaar Updating Action Mailer documentation
mikel authored
352 # implement for a custom delivery agent.
c927aa0 David Heinemeier Hansson Updated documentation
dhh authored
353 #
bb2c7b4 Mikel Lindsaar Updating Action Mailer documentation
mikel authored
354 # * <tt>perform_deliveries</tt> - Determines whether emails are actually sent from Action Mailer when you
5d0d4d8 Sebastian Martinez Remove extra white spaces on ActionMailer docs.
smartinez87 authored
355 # call <tt>.deliver</tt> on an mail message or on an Action Mailer method. This is on by default but can
bb2c7b4 Mikel Lindsaar Updating Action Mailer documentation
mikel authored
356 # be turned off to aid in functional testing.
c927aa0 David Heinemeier Hansson Updated documentation
dhh authored
357 #
bb2c7b4 Mikel Lindsaar Updating Action Mailer documentation
mikel authored
358 # * <tt>deliveries</tt> - Keeps an array of all the emails sent out through the Action Mailer with
359 # <tt>delivery_method :test</tt>. Most useful for unit and functional testing.
af56c80 David Heinemeier Hansson Updated documentation
dhh authored
360 #
4964d3b José Valim Make ActionMailer::Base inherit from AbstractController::Base
josevalim authored
361 class Base < AbstractController::Base
dbcf01e Mikel Lindsaar Removing quoting.rb, upgrade to 2.1.3.6, changing all utf-8 references t...
mikel authored
362 include DeliveryMethods
f30d73b Add new class delivery method API.
José Valim and Mikel Lindsaar authored
363 abstract!
364
c03c40b José Valim Expose a _render_partial hook as thhe _render_template one and make use ...
josevalim authored
365 include AbstractController::Logger
83f4d86 David Heinemeier Hansson Rename the RenderingController module to just plain Rendering
dhh authored
366 include AbstractController::Rendering
a9751a7 José Valim Refactor ActionMailer layout and remove legacy one.
josevalim authored
367 include AbstractController::Layouts
684c2dc José Valim Remove ActionMailer helpers and rely on AbstractController one.
josevalim authored
368 include AbstractController::Helpers
48a3985 José Valim Also include translation in ActionMailer.
josevalim authored
369 include AbstractController::Translation
08baa34 David Heinemeier Hansson Extract assets paths and make them available to Action Mailer as well
dhh authored
370 include AbstractController::AssetPaths
4f28c4f Justin S. Leitgeb Add ability to define callbacks in ActionMailer using AbstractController...
jsl authored
371 include AbstractController::Callbacks
359caef Jamis Buck A very thorough refactoring, resulting in new mail property setters and ...
jamis authored
372
7d86235 Sergey Nartimov get rid of using instance_variable_names method from AS
lest authored
373 self.protected_instance_variables = [:@_action_has_layout]
d42bb68 José Valim More updates to ivars list.
josevalim authored
374
972efa1 José Valim Deprecate the old mailer API that was not deprecated yet.
josevalim authored
375 helper ActionMailer::MailHelper
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
376
c927aa0 David Heinemeier Hansson Updated documentation
dhh authored
377 private_class_method :new #:nodoc:
db045db David Heinemeier Hansson Initial
dhh authored
378
e5ab4b0 Jeremy Kemper Convert to class_attribute
jeremy authored
379 class_attribute :default_params
9dd65c3 Make defaults accept a hash.
José Valim and Mikel Lindsaar authored
380 self.default_params = {
381 :mime_version => "1.0",
dbcf01e Mikel Lindsaar Removing quoting.rb, upgrade to 2.1.3.6, changing all utf-8 references t...
mikel authored
382 :charset => "UTF-8",
9dd65c3 Make defaults accept a hash.
José Valim and Mikel Lindsaar authored
383 :content_type => "text/plain",
384 :parts_order => [ "text/plain", "text/enriched", "text/html" ]
e5ab4b0 Jeremy Kemper Convert to class_attribute
jeremy authored
385 }.freeze
e1c1318 Added delivers_from.
José Valim and Mikel Lindsaar authored
386
eda1719 Jamis Buck ActionMailer::Base.deliver(email) had been accidentally removed, but was...
jamis authored
387 class << self
284ca81 Josh Kalderimis remove AM delegating register_observer and register_interceptor to Mail ...
joshk authored
388 # Register one or more Observers which will be notified when mail is delivered.
389 def register_observers(*observers)
390 observers.flatten.compact.each { |observer| register_observer(observer) }
391 end
392
393 # Register one or more Interceptors which will be called before mail is sent.
394 def register_interceptors(*interceptors)
395 interceptors.flatten.compact.each { |interceptor| register_interceptor(interceptor) }
396 end
397
398 # Register an Observer which will be notified when mail is delivered.
399 # Either a class or a string can be passed in as the Observer. If a string is passed in
400 # it will be <tt>constantize</tt>d.
401 def register_observer(observer)
cb9e501 Josh Kalderimis AM register_interceptor and register_observer only constantize if the ar...
joshk authored
402 delivery_observer = (observer.is_a?(String) ? observer.constantize : observer)
284ca81 Josh Kalderimis remove AM delegating register_observer and register_interceptor to Mail ...
joshk authored
403 Mail.register_observer(delivery_observer)
404 end
405
a467983 Vijay Dev fix typo
vijaydev authored
406 # Register an Interceptor which will be called before mail is sent.
9a67a11 Siong minor typo in the rdoc about Interceptor.
siong1987 authored
407 # Either a class or a string can be passed in as the Interceptor. If a string is passed in
284ca81 Josh Kalderimis remove AM delegating register_observer and register_interceptor to Mail ...
joshk authored
408 # it will be <tt>constantize</tt>d.
409 def register_interceptor(interceptor)
cb9e501 Josh Kalderimis AM register_interceptor and register_observer only constantize if the ar...
joshk authored
410 delivery_interceptor = (interceptor.is_a?(String) ? interceptor.constantize : interceptor)
284ca81 Josh Kalderimis remove AM delegating register_observer and register_interceptor to Mail ...
joshk authored
411 Mail.register_interceptor(delivery_interceptor)
412 end
413
bd5ed65 risk danger olson Update ActionMailer so it treats ActionView the same way that ActionCont...
technoweenie authored
414 def mailer_name
c17d200 Sergey Nartimov mailer can be anonymous
lest authored
415 @mailer_name ||= anonymous? ? "anonymous" : name.underscore
bd5ed65 risk danger olson Update ActionMailer so it treats ActionView the same way that ActionCont...
technoweenie authored
416 end
0750304 Mikel Lindsaar Migrated over to Mail doing delivery.
mikel authored
417 attr_writer :mailer_name
418 alias :controller_path :mailer_name
81c416b José Valim More refactoring on ActionMailer::Base.
josevalim authored
419
e5ab4b0 Jeremy Kemper Convert to class_attribute
jeremy authored
420 def default(value = nil)
421 self.default_params = default_params.merge(value).freeze if value
422 default_params
9dd65c3 Make defaults accept a hash.
José Valim and Mikel Lindsaar authored
423 end
edaa2c4 Robert Pankowecki Introduce config.action_mailer.default_from=
paneq authored
424 #Alias so that we can use it in config/application.rb which requires setters
425 #: config.action_mailer.default_options = {from: "no-replay@example.org"}
426 alias :default_options= :default
9dd65c3 Make defaults accept a hash.
José Valim and Mikel Lindsaar authored
427
59f1df1 Jamis Buck Update/extend ActionMailer documentation (rdoc)
jamis authored
428 # Receives a raw email, parses it into an email object, decodes it,
429 # instantiates a new mailer, and passes the email object to the mailer
98dc582 Pratik Merge docrails.
lifo authored
430 # object's +receive+ method. If you want your mailer to be able to
431 # process incoming messages, you'll need to implement a +receive+
bb2c7b4 Mikel Lindsaar Updating Action Mailer documentation
mikel authored
432 # method that accepts the raw email string as a parameter:
59f1df1 Jamis Buck Update/extend ActionMailer documentation (rdoc)
jamis authored
433 #
434 # class MyMailer < ActionMailer::Base
435 # def receive(mail)
436 # ...
437 # end
438 # end
704daad José Valim Ensure we just send Ruby Stdlib objects in ActionMailer notifications.
josevalim authored
439 def receive(raw_mail)
731d439 Justin George Change event namespace ordering to most-significant first [#4504 state:r...
jaggederest authored
440 ActiveSupport::Notifications.instrument("receive.action_mailer") do |payload|
704daad José Valim Ensure we just send Ruby Stdlib objects in ActionMailer notifications.
josevalim authored
441 mail = Mail.new(raw_mail)
442 set_payload_for_mail(payload, mail)
2a6bc12 José Valim Add subscriber to ActionMailer.
josevalim authored
443 new.receive(mail)
444 end
eda1719 Jamis Buck ActionMailer::Base.deliver(email) had been accidentally removed, but was...
jamis authored
445 end
446
bb2c7b4 Mikel Lindsaar Updating Action Mailer documentation
mikel authored
447 # Wraps an email delivery inside of Active Support Notifications instrumentation. This
de65c82 Rizwan Reza Changes call backs to callbacks.
rizwanreza authored
448 # method is actually called by the <tt>Mail::Message</tt> object itself through a callback
bb2c7b4 Mikel Lindsaar Updating Action Mailer documentation
mikel authored
449 # when you call <tt>:deliver</tt> on the Mail::Message, calling +deliver_mail+ directly
450 # and passing a Mail::Message will do nothing except tell the logger you sent the email.
e4a989e Added delivery_handler method to mail and implemented in ActionMailer to...
José Valim and Mikel Lindsaar authored
451 def deliver_mail(mail) #:nodoc:
731d439 Justin George Change event namespace ordering to most-significant first [#4504 state:r...
jaggederest authored
452 ActiveSupport::Notifications.instrument("deliver.action_mailer") do |payload|
c176397 Sachin Singh some modifications in action_mailer/base.rb
sachin87 authored
453 set_payload_for_mail(payload, mail)
ace7497 Got AM working with Mail yield on delivery_handler and updated tests
José Valim and Mikel Lindsaar authored
454 yield # Let Mail do the delivery actions
258ca14 Delegated ActionMailer::Base.deliveries to Mail.deliveries, added callba...
José Valim and Mikel Lindsaar authored
455 end
456 end
457
ad8dc5a Mikel Lindsaar Should use standard ruby signature for respond_to
mikel authored
458 def respond_to?(method, include_private = false) #:nodoc:
99f960a Handle some TODOs and deprecations.
José Valim and Mikel Lindsaar authored
459 super || action_methods.include?(method.to_s)
460 end
461
a11fcd9 Brian Cardarella Better documentation for ActionMailer.async
bcardarella authored
462 # Will force ActionMailer to push new messages to the queue defined
e2abd8d Francesco Rodríguez fix ActionMailer::Async docs and update to follow coding conventions
frodsan authored
463 # in the ActionMailer class when set to true.
aee4eec Brian Cardarella Better documentation for ActionMailer.async
bcardarella authored
464 #
465 # class WelcomeMailer < ActionMailer::Base
466 # self.async = true
e2abd8d Francesco Rodríguez fix ActionMailer::Async docs and update to follow coding conventions
frodsan authored
467 # end
dc7fd82 Brian Cardarella Asynchronous ActionMailer
bcardarella authored
468 def async=(truth)
469 if truth
470 require 'action_mailer/async'
812d1e8 Brian Cardarella Support for custom queues on the mailer
bcardarella authored
471 extend ActionMailer::Async
dc7fd82 Brian Cardarella Asynchronous ActionMailer
bcardarella authored
472 end
473 end
474
99f960a Handle some TODOs and deprecations.
José Valim and Mikel Lindsaar authored
475 protected
476
704daad José Valim Ensure we just send Ruby Stdlib objects in ActionMailer notifications.
josevalim authored
477 def set_payload_for_mail(payload, mail) #:nodoc:
e8c9cac Aaron Patterson self is implied, so remove self
tenderlove authored
478 payload[:mailer] = name
c905fce José Valim Add message_id to AM payload and don't send bcc and cc if they were not ...
josevalim authored
479 payload[:message_id] = mail.message_id
480 payload[:subject] = mail.subject
481 payload[:to] = mail.to
482 payload[:from] = mail.from
483 payload[:bcc] = mail.bcc if mail.bcc.present?
484 payload[:cc] = mail.cc if mail.cc.present?
485 payload[:date] = mail.date
486 payload[:mail] = mail.encoded
704daad José Valim Ensure we just send Ruby Stdlib objects in ActionMailer notifications.
josevalim authored
487 end
f30d73b Add new class delivery method API.
José Valim and Mikel Lindsaar authored
488
99f960a Handle some TODOs and deprecations.
José Valim and Mikel Lindsaar authored
489 def method_missing(method, *args) #:nodoc:
4d7b2ee Aaron Patterson dry up method missing
tenderlove authored
490 return super unless respond_to?(method)
491 new(method, *args).message
f30d73b Add new class delivery method API.
José Valim and Mikel Lindsaar authored
492 end
eda1719 Jamis Buck ActionMailer::Base.deliver(email) had been accidentally removed, but was...
jamis authored
493 end
494
7409b73 Some refactoring.
José Valim and Mikel Lindsaar authored
495 attr_internal :message
496
6ba9446 Make implicit and explicit templates pass through the same part creation...
José Valim and Mikel Lindsaar authored
497 # Instantiate a new mailer object. If +method_name+ is not +nil+, the mailer
498 # will be initialized according to the named method. If not, the mailer will
499 # remain uninitialized (useful when you only need to invoke the "receive"
500 # method, for instance).
501 def initialize(method_name=nil, *args)
502 super()
7409b73 Some refactoring.
José Valim and Mikel Lindsaar authored
503 @_message = Mail.new
6ba9446 Make implicit and explicit templates pass through the same part creation...
José Valim and Mikel Lindsaar authored
504 process(method_name, *args) if method_name
505 end
506
3fc609e José Valim Fix ActionMailer test broken in 99d54599215c2a8cea7e57f609e8e578043d71b2
josevalim authored
507 def process(*args) #:nodoc:
508 lookup_context.skip_default_locale!
509 super
510 end
511
972efa1 José Valim Deprecate the old mailer API that was not deprecated yet.
josevalim authored
512 def mailer_name
513 self.class.mailer_name
514 end
515
8cc4159 Mark Rushakoff Use <tt>Foo::Bar</tt> instead of +Foo::Bar+
mark-rushakoff authored
516 # Allows you to pass random and unusual headers to the new <tt>Mail::Message</tt> object
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
517 # which will add them to itself.
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
518 #
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
519 # headers['X-Special-Domain-Specific-Header'] = "SecretValue"
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
520 #
9520166 Mikel Lindsaar Fixed up being able to pass random headers in with headers, or mail. Al...
mikel authored
521 # You can also pass a hash into headers of header field names and values, which
522 # will then be set on the Mail::Message object:
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
523 #
05c4ad9 Tidy up tests and docs.
José Valim and Mikel Lindsaar authored
524 # headers 'X-Special-Domain-Specific-Header' => "SecretValue",
525 # 'In-Reply-To' => incoming.message_id
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
526 #
ff44c33 Mark Rushakoff Fix it's -> its
mark-rushakoff authored
527 # The resulting Mail::Message will have the following in its header:
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
528 #
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
529 # X-Special-Domain-Specific-Header: SecretValue
7409b73 Some refactoring.
José Valim and Mikel Lindsaar authored
530 def headers(args=nil)
531 if args
9520166 Mikel Lindsaar Fixed up being able to pass random headers in with headers, or mail. Al...
mikel authored
532 @_message.headers(args)
7409b73 Some refactoring.
José Valim and Mikel Lindsaar authored
533 else
534 @_message
535 end
536 end
c34cfcc Mikel Lindsaar Created mail method for new API
mikel authored
537
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
538 # Allows you to add attachments to an email, like so:
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
539 #
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
540 # mail.attachments['filename.jpg'] = File.read('/path/to/filename.jpg')
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
541 #
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
542 # If you do this, then Mail will take the file name and work out the mime type
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
543 # set the Content-Type, Content-Disposition, Content-Transfer-Encoding and
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
544 # base64 encode the contents of the attachment all for you.
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
545 #
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
546 # You can also specify overrides if you want by passing a hash instead of a string:
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
547 #
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
548 # mail.attachments['filename.jpg'] = {:mime_type => 'application/x-gzip',
549 # :content => File.read('/path/to/filename.jpg')}
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
550 #
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
551 # If you want to use a different encoding than Base64, you can pass an encoding in,
552 # but then it is up to you to pass in the content pre-encoded, and don't expect
553 # Mail to know how to decode this data:
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
554 #
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
555 # file_content = SpecialEncode(File.read('/path/to/filename.jpg'))
556 # mail.attachments['filename.jpg'] = {:mime_type => 'application/x-gzip',
557 # :encoding => 'SpecialEncoding',
558 # :content => file_content }
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
559 #
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
560 # You can also search for specific attachments:
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
561 #
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
562 # # By Filename
755af49 Xavier Noria edit pass to apply API guideline wrt the use of "# =>" in example code
fxn authored
563 # mail.attachments['filename.jpg'] # => Mail::Part object or nil
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
564 #
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
565 # # or by index
755af49 Xavier Noria edit pass to apply API guideline wrt the use of "# =>" in example code
fxn authored
566 # mail.attachments[0] # => Mail::Part (first attachment)
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
567 #
7409b73 Some refactoring.
José Valim and Mikel Lindsaar authored
568 def attachments
569 @_message.attachments
570 end
dcb9253 Add basic template rendering to new DSL.
José Valim and Mikel Lindsaar authored
571
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
572 # The main method that creates the message and renders the email templates. There are
573 # two ways to call this method, with a block, or without a block.
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
574 #
6589976 Remove old files, add some information to docs and improve test suite.
José Valim and Mikel Lindsaar authored
575 # Both methods accept a headers hash. This hash allows you to specify the most used headers
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
576 # in an email message, these are:
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
577 #
058f7fe Mikel Lindsaar Cleaning up Action Mailer spelling with and without the space
mikel authored
578 # * <tt>:subject</tt> - The subject of the message, if this is omitted, Action Mailer will
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
579 # ask the Rails I18n class for a translated <tt>:subject</tt> in the scope of
66880cf Andrew France Correct ActionMailer subject i18n lookup scope.
Odaeus authored
580 # <tt>[mailer_scope, action_name]</tt> or if this is missing, will translate the
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
581 # humanized version of the <tt>action_name</tt>
582 # * <tt>:to</tt> - Who the message is destined for, can be a string of addresses, or an array
583 # of addresses.
0b05acd Mikel Lindsaar Implementing class level :defaults hash, instead of delivers_from et al
mikel authored
584 # * <tt>:from</tt> - Who the message is from
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
585 # * <tt>:cc</tt> - Who you would like to Carbon-Copy on this email, can be a string of addresses,
586 # or an array of addresses.
587 # * <tt>:bcc</tt> - Who you would like to Blind-Carbon-Copy on this email, can be a string of
588 # addresses, or an array of addresses.
589 # * <tt>:reply_to</tt> - Who to set the Reply-To header of the email to.
590 # * <tt>:date</tt> - The date to say the email was sent on.
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
591 #
592 # You can set default values for any of the above headers (except :date) by using the <tt>default</tt>
0b05acd Mikel Lindsaar Implementing class level :defaults hash, instead of delivers_from et al
mikel authored
593 # class method:
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
594 #
9dd65c3 Make defaults accept a hash.
José Valim and Mikel Lindsaar authored
595 # class Notifier < ActionMailer::Base
452bb1e Jeremy Kemper Rename 'defaults' class method to 'default' to reflect that it's a decla...
jeremy authored
596 # self.default :from => 'no-reply@test.lindsaar.net',
597 # :bcc => 'email_logger@test.lindsaar.net',
598 # :reply_to => 'bounces@test.lindsaar.net'
0b05acd Mikel Lindsaar Implementing class level :defaults hash, instead of delivers_from et al
mikel authored
599 # end
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
600 #
52c56f9 Greg Hurrell docs: note that mail() accepts arbitrary headers
wincent authored
601 # If you need other headers not listed above, you can either pass them in
602 # as part of the headers hash or use the <tt>headers['name'] = value</tt>
603 # method.
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
604 #
6589976 Remove old files, add some information to docs and improve test suite.
José Valim and Mikel Lindsaar authored
605 # When a <tt>:return_path</tt> is specified as header, that value will be used as the 'envelope from'
5d0d4d8 Sebastian Martinez Remove extra white spaces on ActionMailer docs.
smartinez87 authored
606 # address for the Mail message. Setting this is useful when you want delivery notifications
607 # sent to a different address than the one in <tt>:from</tt>. Mail will actually use the
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
608 # <tt>:return_path</tt> in preference to the <tt>:sender</tt> in preference to the <tt>:from</tt>
609 # field for the 'envelope from' value.
610 #
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
611 # If you do not pass a block to the +mail+ method, it will find all templates in the
be35a15 José Valim Allow to choose the template path and template name used in implicit ren...
josevalim authored
612 # view paths using by default the mailer name and the method name that it is being
613 # called from, it will then create parts for each of these templates intelligently,
614 # making educated guesses on correct content type and sequence, and return a fully
615 # prepared Mail::Message ready to call <tt>:deliver</tt> on to send.
616 #
617 # For example:
618 #
619 # class Notifier < ActionMailer::Base
620 # default :from => 'no-reply@test.lindsaar.net',
621 #
622 # def welcome
623 # mail(:to => 'mikel@test.lindsaar.net')
624 # end
625 # end
626 #
45b1045 Damien Mathieu raise an error if no implicit mailer template could be found
dmathieu authored
627 # Will look for all templates at "app/views/notifier" with name "welcome".
628 # If no welcome template exists, it will raise an ActionView::MissingTemplate error.
629 #
630 # However, those can be customized:
be35a15 José Valim Allow to choose the template path and template name used in implicit ren...
josevalim authored
631 #
632 # mail(:template_path => 'notifications', :template_name => 'another')
633 #
634 # And now it will look for all templates at "app/views/notifications" with name "another".
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
635 #
636 # If you do pass a block, you can render specific templates of your choice:
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
637 #
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
638 # mail(:to => 'mikel@test.lindsaar.net') do |format|
639 # format.text
640 # format.html
641 # end
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
642 #
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
643 # You can even render text directly without using a template:
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
644 #
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
645 # mail(:to => 'mikel@test.lindsaar.net') do |format|
646 # format.text { render :text => "Hello Mikel!" }
647 # format.html { render :text => "<h1>Hello Mikel!</h1>" }
648 # end
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
649 #
74a5889 Refactor content type setting, added tests to ensure boundary exists on ...
José Valim and Mikel Lindsaar authored
650 # Which will render a <tt>multipart/alternative</tt> email with <tt>text/plain</tt> and
4a6eba3 Added initial documentation for the new API
José Valim and Mikel Lindsaar authored
651 # <tt>text/html</tt> parts.
6589976 Remove old files, add some information to docs and improve test suite.
José Valim and Mikel Lindsaar authored
652 #
653 # The block syntax also allows you to customize the part headers if desired:
654 #
655 # mail(:to => 'mikel@test.lindsaar.net') do |format|
656 # format.text(:content_transfer_encoding => "base64")
657 # format.html
658 # end
659 #
7409b73 Some refactoring.
José Valim and Mikel Lindsaar authored
660 def mail(headers={}, &block)
661 m = @_message
258ca14 Delegated ActionMailer::Base.deliveries to Mail.deliveries, added callba...
José Valim and Mikel Lindsaar authored
662
9dd65c3 Make defaults accept a hash.
José Valim and Mikel Lindsaar authored
663 # At the beginning, do not consider class default for parts order neither content_type
664 content_type = headers[:content_type]
665 parts_order = headers[:parts_order]
1cd5592 First work on implicit multipart.
José Valim and Mikel Lindsaar authored
666
08b07b6 Mikel Lindsaar Adding ability to pass proc's to the ActionMailer class default method
mikel authored
667 # Call all the procs (if any)
c176397 Sachin Singh some modifications in action_mailer/base.rb
sachin87 authored
668 class_default = self.class.default
669 default_values = class_default.merge(class_default) do |k,v|
3fbc042 Sergey Nartimov Use instance_eval instead of Proc#bind
lest authored
670 v.respond_to?(:to_proc) ? instance_eval(&v) : v
08b07b6 Mikel Lindsaar Adding ability to pass proc's to the ActionMailer class default method
mikel authored
671 end
458f571 Yehuda Katz Remove the need for a special action_mailer.url_for initializer that loa...
wycats authored
672
b5f9a9f José Valim Move set_fields! to the old API module.
josevalim authored
673 # Handle defaults
08b07b6 Mikel Lindsaar Adding ability to pass proc's to the ActionMailer class default method
mikel authored
674 headers = headers.reverse_merge(default_values)
9dd65c3 Make defaults accept a hash.
José Valim and Mikel Lindsaar authored
675 headers[:subject] ||= default_i18n_subject
b5f9a9f José Valim Move set_fields! to the old API module.
josevalim authored
676
677 # Apply charset at the beginning so all fields are properly quoted
678 m.charset = charset = headers[:charset]
679
680 # Set configure delivery behavior
681 wrap_delivery_behavior!(headers.delete(:delivery_method))
682
683 # Assign all headers except parts_order, content_type and body
b4fd5e6 José Valim template_name and template_path should not be added to mail headers.
josevalim authored
684 assignable = headers.except(:parts_order, :content_type, :body, :template_name, :template_path)
b5f9a9f José Valim Move set_fields! to the old API module.
josevalim authored
685 assignable.each { |k, v| m[k] = v }
951397b Get implicit multipart and attachments working together.
José Valim and Mikel Lindsaar authored
686
7409b73 Some refactoring.
José Valim and Mikel Lindsaar authored
687 # Render the templates and blocks
39a1b06 Deprecate old defaults API.
José Valim and Mikel Lindsaar authored
688 responses, explicit_order = collect_responses_and_parts_order(headers, &block)
b5f9a9f José Valim Move set_fields! to the old API module.
josevalim authored
689 create_parts_from_responses(m, responses)
7409b73 Some refactoring.
José Valim and Mikel Lindsaar authored
690
b5f9a9f José Valim Move set_fields! to the old API module.
josevalim authored
691 # Setup content type, reapply charset and handle parts order
9dd65c3 Make defaults accept a hash.
José Valim and Mikel Lindsaar authored
692 m.content_type = set_content_type(m, content_type, headers[:content_type])
951397b Get implicit multipart and attachments working together.
José Valim and Mikel Lindsaar authored
693 m.charset = charset
694
e7e4ed4 Set sort order for explicit parts from the collector's template sequence
José Valim and Mikel Lindsaar authored
695 if m.multipart?
9dd65c3 Make defaults accept a hash.
José Valim and Mikel Lindsaar authored
696 parts_order ||= explicit_order || headers[:parts_order]
697 m.body.set_sort_order(parts_order)
951397b Get implicit multipart and attachments working together.
José Valim and Mikel Lindsaar authored
698 m.body.sort_parts!
699 end
bb9d71f Move class methods to deprecated stuff.
José Valim and Mikel Lindsaar authored
700
c34cfcc Mikel Lindsaar Created mail method for new API
mikel authored
701 m
702 end
703
6ba9446 Make implicit and explicit templates pass through the same part creation...
José Valim and Mikel Lindsaar authored
704 protected
705
9dd65c3 Make defaults accept a hash.
José Valim and Mikel Lindsaar authored
706 def set_content_type(m, user_content_type, class_default)
74a5889 Refactor content type setting, added tests to ensure boundary exists on ...
José Valim and Mikel Lindsaar authored
707 params = m.content_type_parameters || {}
708 case
709 when user_content_type.present?
710 user_content_type
711 when m.has_attachments?
311d99e Mikel Lindsaar Adding inline attachment support to ActionMailer
mikel authored
712 if m.attachments.detect { |a| a.inline? }
713 ["multipart", "related", params]
714 else
715 ["multipart", "mixed", params]
716 end
74a5889 Refactor content type setting, added tests to ensure boundary exists on ...
José Valim and Mikel Lindsaar authored
717 when m.multipart?
718 ["multipart", "alternative", params]
719 else
b6b3db6 Mikel Lindsaar Fixed bug on HTML only emails getting set to text/plain
mikel authored
720 m.content_type || class_default
74a5889 Refactor content type setting, added tests to ensure boundary exists on ...
José Valim and Mikel Lindsaar authored
721 end
722 end
723
11b67b3 Indrek Juhkam fix default_i18n_subject comment in ActionMailer::Base
indrekj authored
724 # Translates the +subject+ using Rails I18n class under <tt>[mailer_scope, action_name]</tt> scope.
082e299 Sebastian Martinez docs for ActionMailer::Base.default_i18n_subject
smartinez87 authored
725 # If it does not find a translation for the +subject+ under the specified scope it will default to a
726 # humanized version of the <tt>action_name</tt>.
9dd65c3 Make defaults accept a hash.
José Valim and Mikel Lindsaar authored
727 def default_i18n_subject #:nodoc:
2d8396f Jurriaan Pruis Updated/changed useless tr/gsubs
jurriaan authored
728 mailer_scope = self.class.mailer_name.tr('/', '.')
30eaecb José Valim subject is automatically looked up on I18n using mailer_name and action_...
josevalim authored
729 I18n.t(:subject, :scope => [mailer_scope, action_name], :default => action_name.humanize)
5c3ef8c Refactor subject with i18n.
José Valim and Mikel Lindsaar authored
730 end
731
39a1b06 Deprecate old defaults API.
José Valim and Mikel Lindsaar authored
732 def collect_responses_and_parts_order(headers) #:nodoc:
733 responses, parts_order = [], nil
7409b73 Some refactoring.
José Valim and Mikel Lindsaar authored
734
735 if block_given?
a09e992 José Valim Ensure details are frozen after @details_keys lookup. The implementation...
josevalim authored
736 collector = ActionMailer::Collector.new(lookup_context) { render(action_name) }
7409b73 Some refactoring.
José Valim and Mikel Lindsaar authored
737 yield(collector)
39a1b06 Deprecate old defaults API.
José Valim and Mikel Lindsaar authored
738 parts_order = collector.responses.map { |r| r[:content_type] }
7409b73 Some refactoring.
José Valim and Mikel Lindsaar authored
739 responses = collector.responses
740 elsif headers[:body]
741 responses << {
be35a15 José Valim Allow to choose the template path and template name used in implicit ren...
josevalim authored
742 :body => headers.delete(:body),
452bb1e Jeremy Kemper Rename 'defaults' class method to 'default' to reflect that it's a decla...
jeremy authored
743 :content_type => self.class.default[:content_type] || "text/plain"
7409b73 Some refactoring.
José Valim and Mikel Lindsaar authored
744 }
745 else
be35a15 José Valim Allow to choose the template path and template name used in implicit ren...
josevalim authored
746 templates_path = headers.delete(:template_path) || self.class.mailer_name
747 templates_name = headers.delete(:template_name) || action_name
748
749 each_template(templates_path, templates_name) do |template|
f28d856 José Valim Improve performance of the rendering stack by freezing formats as a sign...
josevalim authored
750 self.formats = template.formats
751
7409b73 Some refactoring.
José Valim and Mikel Lindsaar authored
752 responses << {
2a12686 José Valim Allow anything that responds to render to be given as :template and use ...
josevalim authored
753 :body => render(:template => template),
7409b73 Some refactoring.
José Valim and Mikel Lindsaar authored
754 :content_type => template.mime_type.to_s
755 }
756 end
757 end
758
39a1b06 Deprecate old defaults API.
José Valim and Mikel Lindsaar authored
759 [responses, parts_order]
7409b73 Some refactoring.
José Valim and Mikel Lindsaar authored
760 end
761
be35a15 José Valim Allow to choose the template path and template name used in implicit ren...
josevalim authored
762 def each_template(paths, name, &block) #:nodoc:
3438f6c Rafael Mendonça França Array.wrap is no longer needed here
rafaelfranca authored
763 templates = lookup_context.find_all(name, Array(paths))
45b1045 Damien Mathieu raise an error if no implicit mailer template could be found
dmathieu authored
764 if templates.empty?
765 raise ActionView::MissingTemplate.new([paths], name, [paths], false, 'mailer')
766 else
767 templates.uniq { |t| t.formats }.each(&block)
768 end
99f960a Handle some TODOs and deprecations.
José Valim and Mikel Lindsaar authored
769 end
770
b5f9a9f José Valim Move set_fields! to the old API module.
josevalim authored
771 def create_parts_from_responses(m, responses) #:nodoc:
6ba9446 Make implicit and explicit templates pass through the same part creation...
José Valim and Mikel Lindsaar authored
772 if responses.size == 1 && !m.has_attachments?
9dd65c3 Make defaults accept a hash.
José Valim and Mikel Lindsaar authored
773 responses[0].each { |k,v| m[k] = v }
74a5889 Refactor content type setting, added tests to ensure boundary exists on ...
José Valim and Mikel Lindsaar authored
774 elsif responses.size > 1 && m.has_attachments?
6ba9446 Make implicit and explicit templates pass through the same part creation...
José Valim and Mikel Lindsaar authored
775 container = Mail::Part.new
74a5889 Refactor content type setting, added tests to ensure boundary exists on ...
José Valim and Mikel Lindsaar authored
776 container.content_type = "multipart/alternative"
b5f9a9f José Valim Move set_fields! to the old API module.
josevalim authored
777 responses.each { |r| insert_part(container, r, m.charset) }
6ba9446 Make implicit and explicit templates pass through the same part creation...
José Valim and Mikel Lindsaar authored
778 m.add_part(container)
779 else
b5f9a9f José Valim Move set_fields! to the old API module.
josevalim authored
780 responses.each { |r| insert_part(m, r, m.charset) }
6ba9446 Make implicit and explicit templates pass through the same part creation...
José Valim and Mikel Lindsaar authored
781 end
359caef Jamis Buck A very thorough refactoring, resulting in new mail property setters and ...
jamis authored
782 end
783
6ba9446 Make implicit and explicit templates pass through the same part creation...
José Valim and Mikel Lindsaar authored
784 def insert_part(container, response, charset) #:nodoc:
785 response[:charset] ||= charset
786 part = Mail::Part.new(response)
787 container.add_part(part)
359caef Jamis Buck A very thorough refactoring, resulting in new mail property setters and ...
jamis authored
788 end
3fad0cd David Heinemeier Hansson Added support for charsets for both subject and body. The default charse...
dhh authored
789
ef5dada Natalie Weizenbaum Only run load hooks once a file has been fully loaded.
nex3 authored
790 ActiveSupport.run_load_hooks(:action_mailer, self)
db045db David Heinemeier Hansson Initial
dhh authored
791 end
edaa2c4 Robert Pankowecki Introduce config.action_mailer.default_from=
paneq authored
792 end
Something went wrong with that request. Please try again.