Skip to content
This repository
Newer
Older
100644 629 lines (552 sloc) 26.249 kb
a9751a70 » josevalim
2009-10-17 Refactor ActionMailer layout and remove legacy one.
1 require 'active_support/core_ext/class'
616ebb8f » josevalim
2009-12-28 Remove unused code paths and require mail only when it's needed.
2 require 'mail'
a2880827 » mikel
2009-12-30 Adding :transfer_encoding -> :content_transfer_encoding as part of Tm…
3 require 'action_mailer/tmail_compat'
a63caa4c » Yehuda Katz + Carl Lerche
2009-06-15 Get tests to run (with failures) without old base around
4
c4590d57 » dhh
2006-03-28 Fixed docs
5 module ActionMailer #:nodoc:
98dc5827 » lifo
2008-05-25 Merge docrails.
6 # Action Mailer allows you to send email from your application using a mailer model and views.
db045dbb » dhh
2004-11-24 Initial
7 #
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
8 # = Mailer Models
20bd4bd3 » dhh
2006-09-02 Updated docs and otherwise
9 #
98dc5827 » lifo
2008-05-25 Merge docrails.
10 # To use Action Mailer, you need to create a mailer model.
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
11 #
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
12 # $ script/generate mailer Notifier
13 #
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
14 # The generated model inherits from ActionMailer::Base. Emails are defined by creating methods within the model which are then
15 # used to set variables to be used in the mail template, to change options on the mail, or
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
16 # to add attachments.
17 #
18 # Examples:
19 #
20 # class Notifier < ActionMailer::Base
21 # def signup_notification(recipient)
22 # recipients recipient.email_address_with_name
c3f53f41 » lifo
2008-12-19 Merge docrails
23 # bcc ["bcc@example.com", "Order Watcher <watcher@example.com>"]
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
24 # from "system@example.com"
25 # subject "New account information"
ee70d1b6 » josevalim
2009-12-25 adv_attr_accessors in ActionMailer are not sent to the views, use the…
26 #
27 # @account = recipient
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
28 # end
29 # end
30 #
31 # Mailer methods have the following configuration methods available.
32 #
33 # * <tt>recipients</tt> - Takes one or more email addresses. These addresses are where your email will be delivered to. Sets the <tt>To:</tt> header.
34 # * <tt>subject</tt> - The subject of your email. Sets the <tt>Subject:</tt> header.
35 # * <tt>from</tt> - Who the email you are sending is from. Sets the <tt>From:</tt> header.
36 # * <tt>cc</tt> - Takes one or more email addresses. These addresses will receive a carbon copy of your email. Sets the <tt>Cc:</tt> header.
cf6299db » Adam
2008-05-23 Add ActionMailer#reply_to. [#245 state:resolved]
37 # * <tt>bcc</tt> - Takes one or more email addresses. These addresses will receive a blind carbon copy of your email. Sets the <tt>Bcc:</tt> header.
38 # * <tt>reply_to</tt> - Takes one or more email addresses. These addresses will be listed as the default recipients when replying to your email. Sets the <tt>Reply-To:</tt> header.
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
39 # * <tt>sent_on</tt> - The date on which the message was sent. If not set, the header wil be set by the delivery agent.
40 # * <tt>content_type</tt> - Specify the content type of the message. Defaults to <tt>text/plain</tt>.
41 # * <tt>headers</tt> - Specify additional headers to be set for the message, e.g. <tt>headers 'X-Mail-Count' => 107370</tt>.
42 #
5c0d38f6 » dhh
2008-03-27 Fixed that a return-path header would be ignored (closes #7572) [joost]
43 # When a <tt>headers 'return-path'</tt> is specified, that value will be used as the 'envelope from'
44 # address. Setting this is useful when you want delivery notifications sent to a different address than
45 # the one in <tt>from</tt>.
46 #
20bd4bd3 » dhh
2006-09-02 Updated docs and otherwise
47 #
48 # = Mailer views
49 #
98dc5827 » lifo
2008-05-25 Merge docrails.
50 # Like Action Controller, each mailer class has a corresponding view directory
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
51 # in which each method of the class looks for a template with its name.
21187c0f » dhh
2007-02-21 Apply the rest of Chads patch
52 # To define a template to be used with a mailing, create an <tt>.erb</tt> file with the same name as the method
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
53 # in your mailer model. For example, in the mailer defined above, the template at
21187c0f » dhh
2007-02-21 Apply the rest of Chads patch
54 # <tt>app/views/notifier/signup_notification.erb</tt> would be used to generate the email.
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
55 #
56 # Variables defined in the model are accessible as instance variables in the view.
57 #
58 # Emails by default are sent in plain text, so a sample view for our model example might look like this:
59 #
60 # Hi <%= @account.name %>,
61 # Thanks for joining our service! Please check back often.
62 #
20bd4bd3 » dhh
2006-09-02 Updated docs and otherwise
63 # You can even use Action Pack helpers in these views. For example:
64 #
65 # You got a new note!
ee70d1b6 » josevalim
2009-12-25 adv_attr_accessors in ActionMailer are not sent to the views, use the…
66 # <%= truncate(@note.body, 25) %>
67 #
68 # If you need to access the subject, from or the recipients in the view, you can do that through mailer object:
69 #
70 # You got a new note from <%= mailer.from %>!
71 # <%= truncate(@note.body, 25) %>
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
72 #
20bd4bd3 » dhh
2006-09-02 Updated docs and otherwise
73 #
4809dcc1 » Cody Fauser
2008-04-21 * Remove default_url_options from mailer generator
74 # = Generating URLs
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
75 #
4809dcc1 » Cody Fauser
2008-04-21 * Remove default_url_options from mailer generator
76 # URLs can be generated in mailer views using <tt>url_for</tt> or named routes.
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
77 # Unlike controllers from Action Pack, the mailer instance doesn't have any context about the incoming request,
78 # so you'll need to provide all of the details needed to generate a URL.
20bd4bd3 » dhh
2006-09-02 Updated docs and otherwise
79 #
4809dcc1 » Cody Fauser
2008-04-21 * Remove default_url_options from mailer generator
80 # When using <tt>url_for</tt> you'll need to provide the <tt>:host</tt>, <tt>:controller</tt>, and <tt>:action</tt>:
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
81 #
4809dcc1 » Cody Fauser
2008-04-21 * Remove default_url_options from mailer generator
82 # <%= url_for(:host => "example.com", :controller => "welcome", :action => "greeting") %>
20bd4bd3 » dhh
2006-09-02 Updated docs and otherwise
83 #
4809dcc1 » Cody Fauser
2008-04-21 * Remove default_url_options from mailer generator
84 # When using named routes you only need to supply the <tt>:host</tt>:
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
85 #
4809dcc1 » Cody Fauser
2008-04-21 * Remove default_url_options from mailer generator
86 # <%= users_url(:host => "example.com") %>
87 #
88 # You will want to avoid using the <tt>name_of_route_path</tt> form of named routes because it doesn't make sense to
89 # generate relative URLs in email messages.
90 #
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
91 # It is also possible to set a default host that will be used in all mailers by setting the <tt>:host</tt> option in
4809dcc1 » Cody Fauser
2008-04-21 * Remove default_url_options from mailer generator
92 # the <tt>ActionMailer::Base.default_url_options</tt> hash as follows:
93 #
94 # ActionMailer::Base.default_url_options[:host] = "example.com"
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
95 #
dc4eec11 » lifo
2008-05-09 Merge docrails:
96 # This can also be set as a configuration option in <tt>config/environment.rb</tt>:
4809dcc1 » Cody Fauser
2008-04-21 * Remove default_url_options from mailer generator
97 #
98 # config.action_mailer.default_url_options = { :host => "example.com" }
20bd4bd3 » dhh
2006-09-02 Updated docs and otherwise
99 #
4809dcc1 » Cody Fauser
2008-04-21 * Remove default_url_options from mailer generator
100 # If you do decide to set a default <tt>:host</tt> for your mailers you will want to use the
101 # <tt>:only_path => false</tt> option when using <tt>url_for</tt>. This will ensure that absolute URLs are generated because
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
102 # the <tt>url_for</tt> view helper will, by default, generate relative URLs when a <tt>:host</tt> option isn't
4809dcc1 » Cody Fauser
2008-04-21 * Remove default_url_options from mailer generator
103 # explicitly provided.
20bd4bd3 » dhh
2006-09-02 Updated docs and otherwise
104 #
105 # = Sending mail
106 #
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
107 # Once a mailer action and template are defined, you can deliver your message or create it and save it
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
108 # for delivery later:
109 #
110 # Notifier.deliver_signup_notification(david) # sends the email
111 # mail = Notifier.create_signup_notification(david) # => a tmail object
112 # Notifier.deliver(mail)
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
113 #
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
114 # You never instantiate your mailer class. Rather, your delivery instance
115 # methods are automatically wrapped in class methods that start with the word
116 # <tt>deliver_</tt> followed by the name of the mailer method that you would
117 # like to deliver. The <tt>signup_notification</tt> method defined above is
118 # delivered by invoking <tt>Notifier.deliver_signup_notification</tt>.
119 #
20bd4bd3 » dhh
2006-09-02 Updated docs and otherwise
120 #
121 # = HTML email
122 #
21187c0f » dhh
2007-02-21 Apply the rest of Chads patch
123 # To send mail as HTML, make sure your view (the <tt>.erb</tt> file) generates HTML and
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
124 # set the content type to html.
125 #
126 # class MyMailer < ActionMailer::Base
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
127 # def signup_notification(recipient)
46f30f90 » lifo
2008-05-16 Merge documentation changes from docrails.
128 # recipients recipient.email_address_with_name
129 # subject "New account information"
130 # from "system@example.com"
131 # body :account => recipient
132 # content_type "text/html"
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
133 # end
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
134 # end
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
135 #
20bd4bd3 » dhh
2006-09-02 Updated docs and otherwise
136 #
137 # = Multipart email
138 #
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
139 # You can explicitly specify multipart messages:
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
140 #
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
141 # class ApplicationMailer < ActionMailer::Base
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
142 # def signup_notification(recipient)
143 # recipients recipient.email_address_with_name
144 # subject "New account information"
145 # from "system@example.com"
46f30f90 » lifo
2008-05-16 Merge documentation changes from docrails.
146 # content_type "multipart/alternative"
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
147 #
148 # part :content_type => "text/html",
149 # :body => render_message("signup-as-html", :account => recipient)
150 #
151 # part "text/plain" do |p|
152 # p.body = render_message("signup-as-plain", :account => recipient)
a2880827 » mikel
2009-12-30 Adding :transfer_encoding -> :content_transfer_encoding as part of Tm…
153 # p.content_transfer_encoding = "base64"
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
154 # end
155 # end
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
156 # end
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
157 #
98dc5827 » lifo
2008-05-25 Merge docrails.
158 # Multipart messages can also be used implicitly because Action Mailer will automatically
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
159 # detect and use multipart templates, where each template is named after the name of the action, followed
160 # by the content type. Each such detected template will be added as separate part to the message.
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
161 #
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
162 # For example, if the following templates existed:
21187c0f » dhh
2007-02-21 Apply the rest of Chads patch
163 # * signup_notification.text.plain.erb
164 # * signup_notification.text.html.erb
165 # * signup_notification.text.xml.builder
166 # * signup_notification.text.x-yaml.erb
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
167 #
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
168 # Each would be rendered and added as a separate part to the message,
46f30f90 » lifo
2008-05-16 Merge documentation changes from docrails.
169 # with the corresponding content type. The content type for the entire
170 # message is automatically set to <tt>multipart/alternative</tt>, which indicates
171 # that the email contains multiple different representations of the same email
172 # body. The same body hash is passed to each template.
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
173 #
46f30f90 » lifo
2008-05-16 Merge documentation changes from docrails.
174 # Implicit template rendering is not performed if any attachments or parts have been added to the email.
175 # This means that you'll have to manually add each part to the email and set the content type of the email
176 # to <tt>multipart/alternative</tt>.
20bd4bd3 » dhh
2006-09-02 Updated docs and otherwise
177 #
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
178 # = Attachments
20bd4bd3 » dhh
2006-09-02 Updated docs and otherwise
179 #
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
180 # Attachments can be added by using the +attachment+ method.
181 #
182 # Example:
183 #
184 # class ApplicationMailer < ActionMailer::Base
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
185 # # attachments
186 # def signup_notification(recipient)
187 # recipients recipient.email_address_with_name
188 # subject "New account information"
189 # from "system@example.com"
190 #
191 # attachment :content_type => "image/jpeg",
192 # :body => File.read("an-image.jpg")
193 #
194 # attachment "application/pdf" do |a|
195 # a.body = generate_your_pdf_here()
196 # end
db045dbb » dhh
2004-11-24 Initial
197 # end
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
198 # end
c927aa0f » dhh
2004-12-16 Updated documentation
199 #
20bd4bd3 » dhh
2006-09-02 Updated docs and otherwise
200 #
c927aa0f » dhh
2004-12-16 Updated documentation
201 # = Configuration options
202 #
203 # These options are specified on the class level, like <tt>ActionMailer::Base.template_root = "/my/templates"</tt>
204 #
64092de2 » fxn
2008-05-02 Improve documentation coverage and markup
205 # * <tt>template_root</tt> - Determines the base from which template references will be made.
c927aa0f » dhh
2004-12-16 Updated documentation
206 #
207 # * <tt>logger</tt> - the logger is used for generating information on the mailing run if available.
208 # Can be set to nil for no logging. Compatible with both Ruby's own Logger and Log4r loggers.
209 #
64092de2 » fxn
2008-05-02 Improve documentation coverage and markup
210 # * <tt>smtp_settings</tt> - Allows detailed configuration for <tt>:smtp</tt> delivery method:
dc4eec11 » lifo
2008-05-09 Merge docrails:
211 # * <tt>:address</tt> - Allows you to use a remote mail server. Just change it from its default "localhost" setting.
212 # * <tt>:port</tt> - On the off chance that your mail server doesn't run on port 25, you can change it.
213 # * <tt>:domain</tt> - If you need to specify a HELO domain, you can do it here.
214 # * <tt>:user_name</tt> - If your mail server requires authentication, set the username in this setting.
215 # * <tt>:password</tt> - If your mail server requires authentication, set the password in this setting.
b2504f8b » josh
2008-08-06 Tidy up ActionMailer rendering logic to take advantage of view path c…
216 # * <tt>:authentication</tt> - If your mail server requires authentication, you need to specify the authentication type here.
46f30f90 » lifo
2008-05-16 Merge documentation changes from docrails.
217 # This is a symbol and one of <tt>:plain</tt>, <tt>:login</tt>, <tt>:cram_md5</tt>.
c2e7851f » josevalim
2009-01-11 Add ActionMailer::Base#enable_starttls_auto option for enabling/disab…
218 # * <tt>:enable_starttls_auto</tt> - When set to true, detects if STARTTLS is enabled in your SMTP server and starts to use it.
219 # It works only on Ruby >= 1.8.7 and Ruby >= 1.9. Default is true.
c927aa0f » dhh
2004-12-16 Updated documentation
220 #
46f30f90 » lifo
2008-05-16 Merge documentation changes from docrails.
221 # * <tt>sendmail_settings</tt> - Allows you to override options for the <tt>:sendmail</tt> delivery method.
222 # * <tt>:location</tt> - The location of the sendmail executable. Defaults to <tt>/usr/sbin/sendmail</tt>.
223 # * <tt>:arguments</tt> - The command line arguments. Defaults to <tt>-i -t</tt>.
dc4eec11 » lifo
2008-05-09 Merge docrails:
224 #
fbe6c3c1 » edavis10
2009-08-07 Adds a :file delivery_method to save email to a file on disk
225 # * <tt>file_settings</tt> - Allows you to override options for the <tt>:file</tt> delivery method.
226 # * <tt>:location</tt> - The directory into which emails will be written. Defaults to the application <tt>tmp/mails</tt>.
227 #
dc4eec11 » lifo
2008-05-09 Merge docrails:
228 # * <tt>raise_delivery_errors</tt> - Whether or not errors should be raised if the email fails to be delivered.
c927aa0f » dhh
2004-12-16 Updated documentation
229 #
fbe6c3c1 » edavis10
2009-08-07 Adds a :file delivery_method to save email to a file on disk
230 # * <tt>delivery_method</tt> - Defines a delivery method. Possible values are <tt>:smtp</tt> (default), <tt>:sendmail</tt>, <tt>:test</tt>,
f4f76772 » matthewrudy
2009-10-28 abstract all of the ActionMailer delivery methods into their own clas…
231 # and <tt>:file</tt>. Or you may provide a custom delivery method object eg. MyOwnDeliveryMethodClass.new
c927aa0f » dhh
2004-12-16 Updated documentation
232 #
dc4eec11 » lifo
2008-05-09 Merge docrails:
233 # * <tt>perform_deliveries</tt> - Determines whether <tt>deliver_*</tt> methods are actually carried out. By default they are,
c927aa0f » dhh
2004-12-16 Updated documentation
234 # but this can be turned off to help functional testing.
235 #
64092de2 » fxn
2008-05-02 Improve documentation coverage and markup
236 # * <tt>deliveries</tt> - Keeps an array of all the emails sent out through the Action Mailer with <tt>delivery_method :test</tt>. Most useful
c927aa0f » dhh
2004-12-16 Updated documentation
237 # for unit and functional testing.
af56c806 » dhh
2005-02-24 Updated documentation
238 #
b2504f8b » josh
2008-08-06 Tidy up ActionMailer rendering logic to take advantage of view path c…
239 # * <tt>default_charset</tt> - The default charset used for the body and to encode the subject. Defaults to UTF-8. You can also
46f30f90 » lifo
2008-05-16 Merge documentation changes from docrails.
240 # pick a different charset from inside a method with +charset+.
c2e7851f » josevalim
2009-01-11 Add ActionMailer::Base#enable_starttls_auto option for enabling/disab…
241 #
475bd741 » dhh
2005-10-26 Fix docs (closes #2598)
242 # * <tt>default_content_type</tt> - The default content type used for the main part of the message. Defaults to "text/plain". You
b2504f8b » josh
2008-08-06 Tidy up ActionMailer rendering logic to take advantage of view path c…
243 # can also pick a different content type from inside a method with +content_type+.
c2e7851f » josevalim
2009-01-11 Add ActionMailer::Base#enable_starttls_auto option for enabling/disab…
244 #
46f30f90 » lifo
2008-05-16 Merge documentation changes from docrails.
245 # * <tt>default_mime_version</tt> - The default mime version used for the message. Defaults to <tt>1.0</tt>. You
246 # can also pick a different value from inside a method with +mime_version+.
c2e7851f » josevalim
2009-01-11 Add ActionMailer::Base#enable_starttls_auto option for enabling/disab…
247 #
475bd741 » dhh
2005-10-26 Fix docs (closes #2598)
248 # * <tt>default_implicit_parts_order</tt> - When a message is built implicitly (i.e. multiple parts are assembled from templates
5c981528 » jamis
2005-07-01 Better multipart support with implicit multipart/alternative and sort…
249 # which specify the content type in their filenames) this variable controls how the parts are ordered. Defaults to
46f30f90 » lifo
2008-05-16 Merge documentation changes from docrails.
250 # <tt>["text/html", "text/enriched", "text/plain"]</tt>. Items that appear first in the array have higher priority in the mail client
5c981528 » jamis
2005-07-01 Better multipart support with implicit multipart/alternative and sort…
251 # and appear last in the mime encoded message. You can also pick a different order from inside a method with
46f30f90 » lifo
2008-05-16 Merge documentation changes from docrails.
252 # +implicit_parts_order+.
4964d3b0 » josevalim
2009-12-22 Make ActionMailer::Base inherit from AbstractController::Base
253 class Base < AbstractController::Base
47e5caa9 » josevalim
2009-12-27 Merge Mail with latest Rails and move mail gem to Gemfile.
254 include Quoting
ee70d1b6 » josevalim
2009-12-25 adv_attr_accessors in ActionMailer are not sent to the views, use the…
255 extend AdvAttrAccessor
a9751a70 » josevalim
2009-10-17 Refactor ActionMailer layout and remove legacy one.
256
c03c40b4 » josevalim
2009-12-31 Expose a _render_partial hook as thhe _render_template one and make u…
257 include AbstractController::Logger
83f4d86a » dhh
2009-12-20 Rename the RenderingController module to just plain Rendering
258 include AbstractController::Rendering
976c2647 » josevalim
2009-10-28 Extracted localized_cache.rb from ActionController, added it to Abstr…
259 include AbstractController::LocalizedCache
a9751a70 » josevalim
2009-10-17 Refactor ActionMailer layout and remove legacy one.
260 include AbstractController::Layouts
684c2dc2 » josevalim
2009-10-18 Remove ActionMailer helpers and rely on AbstractController one.
261 include AbstractController::Helpers
f564f947 » josevalim
2010-01-07 Remove duplicated url_for code and move methods shared between Action…
262 include AbstractController::UrlFor
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
263
ee70d1b6 » josevalim
2009-12-25 adv_attr_accessors in ActionMailer are not sent to the views, use the…
264 helper ActionMailer::MailHelper
418c3f80 » josevalim
2009-10-21 Another refactoring on AM. body is deprecated, use render instead.
265 include ActionMailer::DeprecatedBody
266
c927aa0f » dhh
2004-12-16 Updated documentation
267 private_class_method :new #:nodoc:
db045dbb » dhh
2004-11-24 Initial
268
269 @@raise_delivery_errors = true
270 cattr_accessor :raise_delivery_errors
271
272 @@perform_deliveries = true
273 cattr_accessor :perform_deliveries
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
274
db045dbb » dhh
2004-11-24 Initial
275 @@deliveries = []
276 cattr_accessor :deliveries
277
3fad0cd0 » dhh
2005-02-19 Added support for charsets for both subject and body. The default cha…
278 @@default_charset = "utf-8"
279 cattr_accessor :default_charset
280
100fd726 » jamis
2005-06-03 Added a "content_type" accessor to allow messages to explicitly speci…
281 @@default_content_type = "text/plain"
282 cattr_accessor :default_content_type
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
283
45b5555f » jamis
2006-09-09 Make mime version default to 1.0. closes #2323
284 @@default_mime_version = "1.0"
dca4d4e8 » jamis
2005-08-22 Multipart messages specify a MIME-Version header automatically #2003
285 cattr_accessor :default_mime_version
100fd726 » jamis
2005-06-03 Added a "content_type" accessor to allow messages to explicitly speci…
286
c039bcdb » mikel
2009-12-28 Moved sort_parts into Mail, updated mail requirement to 1.4.2
287 # This specifies the order that the parts of a multipart email will be. Usually you put
288 # text/plain at the top so someone without a MIME capable email reader can read the plain
289 # text of your email first.
290 #
291 # Any content type that is not listed here will be inserted in the order you add them to
292 # the email after the content types you list here.
293 @@default_implicit_parts_order = [ "text/plain", "text/enriched", "text/html" ]
5c981528 » jamis
2005-07-01 Better multipart support with implicit multipart/alternative and sort…
294 cattr_accessor :default_implicit_parts_order
295
ee70d1b6 » josevalim
2009-12-25 adv_attr_accessors in ActionMailer are not sent to the views, use the…
296 @@protected_instance_variables = %w(@parts @mail)
81c416b7 » josevalim
2009-10-28 More refactoring on ActionMailer::Base.
297 cattr_reader :protected_instance_variables
28bf2fa0 » josh
2008-09-28 Protect body ivar from being clobbered by the mailer template assigns
298
59f1df1b » jamis
2005-10-16 Update/extend ActionMailer documentation (rdoc)
299 # Specify the BCC addresses for the message
300 adv_attr_accessor :bcc
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
301
59f1df1b » jamis
2005-10-16 Update/extend ActionMailer documentation (rdoc)
302 # Specify the CC addresses for the message.
303 adv_attr_accessor :cc
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
304
59f1df1b » jamis
2005-10-16 Update/extend ActionMailer documentation (rdoc)
305 # Specify the charset to use for the message. This defaults to the
306 # +default_charset+ specified for ActionMailer::Base.
307 adv_attr_accessor :charset
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
308
59f1df1b » jamis
2005-10-16 Update/extend ActionMailer documentation (rdoc)
309 # Specify the content type for the message. This defaults to <tt>text/plain</tt>
310 # in most cases, but can be automatically set in some situations.
311 adv_attr_accessor :content_type
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
312
59f1df1b » jamis
2005-10-16 Update/extend ActionMailer documentation (rdoc)
313 # Specify the from address for the message.
314 adv_attr_accessor :from
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
315
cf6299db » Adam
2008-05-23 Add ActionMailer#reply_to. [#245 state:resolved]
316 # Specify the address (if different than the "from" address) to direct
317 # replies to this message.
318 adv_attr_accessor :reply_to
319
59f1df1b » jamis
2005-10-16 Update/extend ActionMailer documentation (rdoc)
320 # Specify additional headers to be added to the message.
321 adv_attr_accessor :headers
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
322
59f1df1b » jamis
2005-10-16 Update/extend ActionMailer documentation (rdoc)
323 # Specify the order in which parts should be sorted, based on content-type.
324 # This defaults to the value for the +default_implicit_parts_order+.
325 adv_attr_accessor :implicit_parts_order
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
326
59f1df1b » jamis
2005-10-16 Update/extend ActionMailer documentation (rdoc)
327 # Defaults to "1.0", but may be explicitly given if needed.
328 adv_attr_accessor :mime_version
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
329
59f1df1b » jamis
2005-10-16 Update/extend ActionMailer documentation (rdoc)
330 # The recipient addresses for the message, either as a string (for a single
331 # address) or an array (for multiple addresses).
332 adv_attr_accessor :recipients
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
333
59f1df1b » jamis
2005-10-16 Update/extend ActionMailer documentation (rdoc)
334 # The date on which the message was sent. If not set (the default), the
335 # header will be set by the delivery agent.
336 adv_attr_accessor :sent_on
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
337
59f1df1b » jamis
2005-10-16 Update/extend ActionMailer documentation (rdoc)
338 # Specify the subject of the message.
339 adv_attr_accessor :subject
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
340
59f1df1b » jamis
2005-10-16 Update/extend ActionMailer documentation (rdoc)
341 # Specify the template name to use for current message. This is the "base"
342 # template name, without the extension or directory, and may be used to
343 # have multiple mailer methods share the same template.
344 adv_attr_accessor :template
165097ed » dhh
2004-12-07 Added access to custom headers, like cc, bcc, and reply-to #268 [Andr…
345
bd5ed651 » technoweenie
2007-11-26 Update ActionMailer so it treats ActionView the same way that ActionC…
346 # Override the mailer name, which defaults to an inflected version of the
347 # mailer's class name. If you want to use a template in a non-standard
348 # location, you can use this to specify that location.
4964d3b0 » josevalim
2009-12-22 Make ActionMailer::Base inherit from AbstractController::Base
349 adv_attr_accessor :mailer_name
418c3f80 » josevalim
2009-10-21 Another refactoring on AM. body is deprecated, use render instead.
350
4964d3b0 » josevalim
2009-12-22 Make ActionMailer::Base inherit from AbstractController::Base
351 # Expose the internal mail
352 attr_reader :mail
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
353
418c3f80 » josevalim
2009-10-21 Another refactoring on AM. body is deprecated, use render instead.
354 # Alias controller_path to mailer_name so render :partial in views work.
355 alias :controller_path :mailer_name
43d5504f » josevalim
2009-10-18 Move all render and layout pieces required in ActionMailer from Actio…
356
eda17194 » jamis
2005-07-31 ActionMailer::Base.deliver(email) had been accidentally removed, but …
357 class << self
bd5ed651 » technoweenie
2007-11-26 Update ActionMailer so it treats ActionView the same way that ActionC…
358 attr_writer :mailer_name
359
81c416b7 » josevalim
2009-10-28 More refactoring on ActionMailer::Base.
360 delegate :settings, :settings=, :to => ActionMailer::DeliveryMethod::File, :prefix => :file
361 delegate :settings, :settings=, :to => ActionMailer::DeliveryMethod::Sendmail, :prefix => :sendmail
362 delegate :settings, :settings=, :to => ActionMailer::DeliveryMethod::Smtp, :prefix => :smtp
363
bd5ed651 » technoweenie
2007-11-26 Update ActionMailer so it treats ActionView the same way that ActionC…
364 def mailer_name
365 @mailer_name ||= name.underscore
366 end
38fa0d14 » josevalim
2009-12-31 controller_path is required by ActionView, so move it up to AbstractC…
367 alias :controller_path :mailer_name
bd5ed651 » technoweenie
2007-11-26 Update ActionMailer so it treats ActionView the same way that ActionC…
368
81c416b7 » josevalim
2009-10-28 More refactoring on ActionMailer::Base.
369 def delivery_method=(method_name)
370 @delivery_method = ActionMailer::DeliveryMethod.lookup_method(method_name)
371 end
372
3cf773b1 » floehopper
2008-08-29 ActionMailer should respond_to? to methods handled by method_missing [#…
373 def respond_to?(method_symbol, include_private = false) #:nodoc:
374 matches_dynamic_method?(method_symbol) || super
375 end
376
377 def method_missing(method_symbol, *parameters) #:nodoc:
a62e9e90 » mocoso
2008-11-11 Fix for ActionMailer::Base.method_missing so that it raises NoMethodE…
378 if match = matches_dynamic_method?(method_symbol)
379 case match[1]
380 when 'create' then new(match[2], *parameters).mail
381 when 'deliver' then new(match[2], *parameters).deliver!
382 when 'new' then nil
c65075fe » mocoso
2008-11-11 Fixed method_missing for ActionMailer so it no longer matches methods…
383 else super
a62e9e90 » mocoso
2008-11-11 Fix for ActionMailer::Base.method_missing so that it raises NoMethodE…
384 end
385 else
386 super
eda17194 » jamis
2005-07-31 ActionMailer::Base.deliver(email) had been accidentally removed, but …
387 end
388 end
389
59f1df1b » jamis
2005-10-16 Update/extend ActionMailer documentation (rdoc)
390 # Receives a raw email, parses it into an email object, decodes it,
391 # instantiates a new mailer, and passes the email object to the mailer
98dc5827 » lifo
2008-05-25 Merge docrails.
392 # object's +receive+ method. If you want your mailer to be able to
393 # process incoming messages, you'll need to implement a +receive+
59f1df1b » jamis
2005-10-16 Update/extend ActionMailer documentation (rdoc)
394 # method that accepts the email object as a parameter:
395 #
396 # class MyMailer < ActionMailer::Base
397 # def receive(mail)
398 # ...
399 # end
400 # end
704daad7 » josevalim
2010-01-15 Ensure we just send Ruby Stdlib objects in ActionMailer notifications.
401 def receive(raw_mail)
402 ActiveSupport::Notifications.instrument("action_mailer.receive") do |payload|
403 mail = Mail.new(raw_mail)
404 set_payload_for_mail(payload, mail)
2a6bc126 » josevalim
2010-01-13 Add subscriber to ActionMailer.
405 new.receive(mail)
406 end
eda17194 » jamis
2005-07-31 ActionMailer::Base.deliver(email) had been accidentally removed, but …
407 end
408
409 # Deliver the given mail object directly. This can be used to deliver
410 # a preconstructed mail object, like:
411 #
412 # email = MyMailer.create_some_mail(parameters)
413 # email.set_some_obscure_header "frobnicate"
414 # MyMailer.deliver(email)
415 def deliver(mail)
416 new.deliver!(mail)
417 end
271404e8 » jeremy
2007-06-07 Register alternative template engines using ActionMailer::Base.regist…
418
cb21db1a » josh
2008-07-31 Treat ActionMailer template_root as a view path set internally to avo…
419 def template_root
420 self.view_paths && self.view_paths.first
421 end
422
684c2dc2 » josevalim
2009-10-18 Remove ActionMailer helpers and rely on AbstractController one.
423 # Should template root overwrite the whole view_paths?
61c90a4a » NZKoz
2008-01-21 Reapply the TemplateFinder first applied in [8669] then reverted in […
424 def template_root=(root)
cb21db1a » josh
2008-07-31 Treat ActionMailer template_root as a view path set internally to avo…
425 self.view_paths = ActionView::Base.process_view_paths(root)
61c90a4a » NZKoz
2008-01-21 Reapply the TemplateFinder first applied in [8669] then reverted in […
426 end
3cf773b1 » floehopper
2008-08-29 ActionMailer should respond_to? to methods handled by method_missing [#…
427
704daad7 » josevalim
2010-01-15 Ensure we just send Ruby Stdlib objects in ActionMailer notifications.
428 def set_payload_for_mail(payload, mail) #:nodoc:
c905fce3 » josevalim
2010-01-15 Add message_id to AM payload and don't send bcc and cc if they were n…
429 payload[:message_id] = mail.message_id
430 payload[:subject] = mail.subject
431 payload[:to] = mail.to
432 payload[:from] = mail.from
433 payload[:bcc] = mail.bcc if mail.bcc.present?
434 payload[:cc] = mail.cc if mail.cc.present?
435 payload[:date] = mail.date
436 payload[:mail] = mail.encoded
704daad7 » josevalim
2010-01-15 Ensure we just send Ruby Stdlib objects in ActionMailer notifications.
437 end
438
3cf773b1 » floehopper
2008-08-29 ActionMailer should respond_to? to methods handled by method_missing [#…
439 private
704daad7 » josevalim
2010-01-15 Ensure we just send Ruby Stdlib objects in ActionMailer notifications.
440
3cf773b1 » floehopper
2008-08-29 ActionMailer should respond_to? to methods handled by method_missing [#…
441 def matches_dynamic_method?(method_name) #:nodoc:
442 method_name = method_name.to_s
c65075fe » mocoso
2008-11-11 Fixed method_missing for ActionMailer so it no longer matches methods…
443 /^(create|deliver)_([_a-z]\w*)/.match(method_name) || /^(new)$/.match(method_name)
3cf773b1 » floehopper
2008-08-29 ActionMailer should respond_to? to methods handled by method_missing [#…
444 end
eda17194 » jamis
2005-07-31 ActionMailer::Base.deliver(email) had been accidentally removed, but …
445 end
446
81c416b7 » josevalim
2009-10-28 More refactoring on ActionMailer::Base.
447 # Configure delivery method. Check ActionMailer::DeliveryMethod for more
448 # instructions.
449 superclass_delegating_reader :delivery_method
450 self.delivery_method = :smtp
451
971f4ff8 » josevalim
2009-12-27 DRY ActionMailer code.
452 # Add a part to a multipart message, with the given content-type. The
453 # part itself is yielded to the block so that other properties (charset,
454 # body, headers, etc.) can be set on it.
455 def part(params)
456 params = {:content_type => params} if String === params
457 if custom_headers = params.delete(:headers)
458 ActiveSupport::Deprecation.warn('Passing custom headers with :headers => {} is deprecated. ' <<
459 'Please just pass in custom headers directly.', caller[0,10])
460 params.merge!(custom_headers)
461 end
462 part = Mail::Part.new(params)
463 yield part if block_given?
464 @parts << part
465 end
466
467 # Add an attachment to a multipart message. This is simply a part with the
468 # content-disposition set to "attachment".
469 def attachment(params, &block)
470 super # Run deprecation hooks
471
472 params = { :content_type => params } if String === params
473 params = { :content_disposition => "attachment",
474 :content_transfer_encoding => "base64" }.merge(params)
475
476 part(params, &block)
477 end
478
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
479 # Instantiate a new mailer object. If +method_name+ is not +nil+, the mailer
480 # will be initialized according to the named method. If not, the mailer will
481 # remain uninitialized (useful when you only need to invoke the "receive"
482 # method, for instance).
971f4ff8 » josevalim
2009-12-27 DRY ActionMailer code.
483 def initialize(method_name=nil, *args)
d887e46c » jeremy
2009-11-10 Be sure to invoke the super chain! And initialize response body.
484 super()
4964d3b0 » josevalim
2009-12-22 Make ActionMailer::Base inherit from AbstractController::Base
485 process(method_name, *args) if method_name
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
486 end
487
4964d3b0 » josevalim
2009-12-22 Make ActionMailer::Base inherit from AbstractController::Base
488 # Process the mailer via the given +method_name+. The body will be
971f4ff8 » josevalim
2009-12-27 DRY ActionMailer code.
489 # rendered and a new Mail object created.
490 def process(method_name, *args)
43d5504f » josevalim
2009-10-18 Move all render and layout pieces required in ActionMailer from Actio…
491 initialize_defaults(method_name)
4964d3b0 » josevalim
2009-12-22 Make ActionMailer::Base inherit from AbstractController::Base
492 super
43d5504f » josevalim
2009-10-18 Move all render and layout pieces required in ActionMailer from Actio…
493
418c3f80 » josevalim
2009-10-21 Another refactoring on AM. body is deprecated, use render instead.
494 # Create e-mail parts
495 create_parts
09f798ba » josevalim
2009-09-20 Instrument create and deliver in ActionMailer.
496
2aafdc83 » josevalim
2009-10-28 Use I18n on ActionMailer subjects by default.
497 # Set the subject if not set yet
4a1f4387 » josevalim
2009-11-09 Change mailer subjects lookup.
498 @subject ||= I18n.t(:subject, :scope => [:actionmailer, mailer_name, method_name],
499 :default => method_name.humanize)
43d5504f » josevalim
2009-10-18 Move all render and layout pieces required in ActionMailer from Actio…
500
4964d3b0 » josevalim
2009-12-22 Make ActionMailer::Base inherit from AbstractController::Base
501 # Build the mail object itself
88ba0560 » josevalim
2009-12-25 Refactor multiple parts logic and move Utils to PartContainer.
502 create_mail
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
503 end
db045dbb » dhh
2004-11-24 Initial
504
15d7cac2 » mikel
2009-11-12 Starting again on actionmailer integration with mail
505 # Delivers a Mail object. By default, it delivers the cached mail
98dc5827 » lifo
2008-05-25 Merge docrails.
506 # object (from the <tt>create!</tt> method). If no cached mail object exists, and
eda17194 » jamis
2005-07-31 ActionMailer::Base.deliver(email) had been accidentally removed, but …
507 # no alternate has been given as the parameter, this will fail.
59f1df1b » jamis
2005-10-16 Update/extend ActionMailer documentation (rdoc)
508 def deliver!(mail = @mail)
eda17194 » jamis
2005-07-31 ActionMailer::Base.deliver(email) had been accidentally removed, but …
509 raise "no mail object available for delivery!" unless mail
09f798ba » josevalim
2009-09-20 Instrument create and deliver in ActionMailer.
510
2a6bc126 » josevalim
2010-01-13 Add subscriber to ActionMailer.
511 begin
512 ActiveSupport::Notifications.instrument("action_mailer.deliver",
704daad7 » josevalim
2010-01-15 Ensure we just send Ruby Stdlib objects in ActionMailer notifications.
513 :template => template, :mailer_name => mailer_name) do |payload|
514 self.class.set_payload_for_mail(payload, mail)
f4f76772 » matthewrudy
2009-10-28 abstract all of the ActionMailer delivery methods into their own clas…
515 self.delivery_method.perform_delivery(mail) if perform_deliveries
09f798ba » josevalim
2009-09-20 Instrument create and deliver in ActionMailer.
516 end
2a6bc126 » josevalim
2010-01-13 Add subscriber to ActionMailer.
517 rescue Exception => e # Net::SMTP errors or sendmail pipe errors
518 raise e if raise_delivery_errors
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
519 end
3fad0cd0 » dhh
2005-02-19 Added support for charsets for both subject and body. The default cha…
520
09f798ba » josevalim
2009-09-20 Instrument create and deliver in ActionMailer.
521 mail
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
522 end
3fad0cd0 » dhh
2005-02-19 Added support for charsets for both subject and body. The default cha…
523
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
524 private
418c3f80 » josevalim
2009-10-21 Another refactoring on AM. body is deprecated, use render instead.
525
f474f337 » jamis
2005-08-22 Move mailer initialization to a separate (overridable) method, so tha…
526 # Set up the default values for the various instance variables of this
527 # mailer. Subclasses may override this method to provide different
528 # defaults.
971f4ff8 » josevalim
2009-12-27 DRY ActionMailer code.
529 def initialize_defaults(method_name) #:nodoc:
81c416b7 » josevalim
2009-10-28 More refactoring on ActionMailer::Base.
530 @charset ||= @@default_charset.dup
531 @content_type ||= @@default_content_type.dup
95e8740f » dhh
2005-10-26 Allow Mailers to have custom initialize methods that set default inst…
532 @implicit_parts_order ||= @@default_implicit_parts_order.dup
81c416b7 » josevalim
2009-10-28 More refactoring on ActionMailer::Base.
533 @mime_version ||= @@default_mime_version.dup if @@default_mime_version
534
4964d3b0 » josevalim
2009-12-22 Make ActionMailer::Base inherit from AbstractController::Base
535 @mailer_name ||= self.class.mailer_name.dup
81c416b7 » josevalim
2009-10-28 More refactoring on ActionMailer::Base.
536 @template ||= method_name
537
538 @parts ||= []
95e8740f » dhh
2005-10-26 Allow Mailers to have custom initialize methods that set default inst…
539 @headers ||= {}
5fdc33c1 » mrduncan
2009-08-07 Default sent_on time to now in ActionMailer
540 @sent_on ||= Time.now
f474f337 » jamis
2005-08-22 Move mailer initialization to a separate (overridable) method, so tha…
541
4964d3b0 » josevalim
2009-12-22 Make ActionMailer::Base inherit from AbstractController::Base
542 super # Run deprecation hooks
6228220c » dhh
2008-09-09 Revert "Revert "Add layout functionality to mailers.""
543 end
544
971f4ff8 » josevalim
2009-12-27 DRY ActionMailer code.
545 def create_parts #:nodoc:
4964d3b0 » josevalim
2009-12-22 Make ActionMailer::Base inherit from AbstractController::Base
546 super # Run deprecation hooks
cb21db1a » josh
2008-07-31 Treat ActionMailer template_root as a view path set internally to avo…
547
418c3f80 » josevalim
2009-10-21 Another refactoring on AM. body is deprecated, use render instead.
548 if String === response_body
971f4ff8 » josevalim
2009-12-27 DRY ActionMailer code.
549 @parts.unshift create_inline_part(response_body)
418c3f80 » josevalim
2009-10-21 Another refactoring on AM. body is deprecated, use render instead.
550 else
616ebb8f » josevalim
2009-12-28 Remove unused code paths and require mail only when it's needed.
551 self.class.template_root.find_all(@template, {}, @mailer_name).each do |template|
971f4ff8 » josevalim
2009-12-27 DRY ActionMailer code.
552 @parts << create_inline_part(render_to_body(:_template => template), template.mime_type)
418c3f80 » josevalim
2009-10-21 Another refactoring on AM. body is deprecated, use render instead.
553 end
cb21db1a » josh
2008-07-31 Treat ActionMailer template_root as a view path set internally to avo…
554
418c3f80 » josevalim
2009-10-21 Another refactoring on AM. body is deprecated, use render instead.
555 if @parts.size > 1
556 @content_type = "multipart/alternative" if @content_type !~ /^multipart/
557 end
2aafdc83 » josevalim
2009-10-28 Use I18n on ActionMailer subjects by default.
558
559 # If this is a multipart e-mail add the mime_version if it is not
560 # already set.
561 @mime_version ||= "1.0" if !@parts.empty?
418c3f80 » josevalim
2009-10-21 Another refactoring on AM. body is deprecated, use render instead.
562 end
db045dbb » dhh
2004-11-24 Initial
563 end
564
971f4ff8 » josevalim
2009-12-27 DRY ActionMailer code.
565 def create_inline_part(body, mime_type=nil) #:nodoc:
566 ct = mime_type || "text/plain"
567 main_type, sub_type = split_content_type(ct.to_s)
568
569 Mail::Part.new(
570 :content_type => [main_type, sub_type, {:charset => charset}],
571 :content_disposition => "inline",
572 :body => body
573 )
574 end
575
576 def create_mail #:nodoc:
15d7cac2 » mikel
2009-11-12 Starting again on actionmailer integration with mail
577 m = Mail.new
74a612c4 » dhh
2005-05-02 Added that delivery errors are caught in a way so the mail is still r…
578
cf6299db » Adam
2008-05-23 Add ActionMailer#reply_to. [#245 state:resolved]
579 m.subject, = quote_any_if_necessary(charset, subject)
580 m.to, m.from = quote_any_address_if_necessary(charset, recipients, from)
581 m.bcc = quote_address_if_necessary(bcc, charset) unless bcc.nil?
582 m.cc = quote_address_if_necessary(cc, charset) unless cc.nil?
583 m.reply_to = quote_address_if_necessary(reply_to, charset) unless reply_to.nil?
dca4d4e8 » jamis
2005-08-22 Multipart messages specify a MIME-Version header automatically #2003
584 m.mime_version = mime_version unless mime_version.nil?
cf6299db » Adam
2008-05-23 Add ActionMailer#reply_to. [#245 state:resolved]
585 m.date = sent_on.to_time rescue sent_on if sent_on
586
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
587 headers.each { |k, v| m[k] = v }
db045dbb » dhh
2004-11-24 Initial
588
db0e8ff1 » jamis
2006-03-18 Parse content-type apart before using it so that sub-parts of the hea…
589 real_content_type, ctype_attrs = parse_content_type
971f4ff8 » josevalim
2009-12-27 DRY ActionMailer code.
590 main_type, sub_type = split_content_type(real_content_type)
5d9af095 » josh
2009-12-01 Silence known internal AM deprecation calls
591
616ebb8f » josevalim
2009-12-28 Remove unused code paths and require mail only when it's needed.
592 if @parts.size == 1 && @parts.first.parts.empty?
a5e6295d » mikel
2009-11-20 Down to 30 failures total
593 m.content_type([main_type, sub_type, ctype_attrs])
a6eed86c » mikel
2009-11-23 Removing utils, and updating requires to match
594 m.body = @parts.first.body.encoded
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
595 else
596 @parts.each do |p|
747d5688 » mikel
2009-11-22 131 tests, 309 assertions, 0 failures, 0 errors
597 m.add_part(p)
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
598 end
616ebb8f » josevalim
2009-12-28 Remove unused code paths and require mail only when it's needed.
599
c039bcdb » mikel
2009-12-28 Moved sort_parts into Mail, updated mail requirement to 1.4.2
600 m.body.set_sort_order(@implicit_parts_order)
601 m.body.sort_parts!
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
602
49efa02b » jamis
2006-03-19 Nil charset caused subject line to be improperly quoted in implicitly…
603 if real_content_type =~ /multipart/
604 ctype_attrs.delete "charset"
a5e6295d » mikel
2009-11-20 Down to 30 failures total
605 m.content_type([main_type, sub_type, ctype_attrs])
49efa02b » jamis
2006-03-19 Nil charset caused subject line to be improperly quoted in implicitly…
606 end
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
607 end
256e800a » dhh
2005-04-11 Fixed quoting for all address headers, not just to #955 [Jamis Buck] …
608
b354496b » mikel
2009-12-28 Adding default 8bit encoding if the body has non usascii in it
609 m.content_transfer_encoding = '8bit' unless m.body.only_us_ascii?
610
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
611 @mail = m
256e800a » dhh
2005-04-11 Fixed quoting for all address headers, not just to #955 [Jamis Buck] …
612 end
539d9b35 » mikel
2009-11-20 More updates... 45 errors left to get it working with Mail gem
613
971f4ff8 » josevalim
2009-12-27 DRY ActionMailer code.
614 def split_content_type(ct) #:nodoc:
539d9b35 » mikel
2009-11-20 More updates... 45 errors left to get it working with Mail gem
615 ct.to_s.split("/")
616 end
256e800a » dhh
2005-04-11 Fixed quoting for all address headers, not just to #955 [Jamis Buck] …
617
971f4ff8 » josevalim
2009-12-27 DRY ActionMailer code.
618 def parse_content_type(defaults=nil) #:nodoc:
616ebb8f » josevalim
2009-12-28 Remove unused code paths and require mail only when it's needed.
619 if @content_type.blank?
620 [ nil, {} ]
971f4ff8 » josevalim
2009-12-27 DRY ActionMailer code.
621 else
616ebb8f » josevalim
2009-12-28 Remove unused code paths and require mail only when it's needed.
622 ctype, *attrs = @content_type.split(/;\s*/)
971f4ff8 » josevalim
2009-12-27 DRY ActionMailer code.
623 attrs = attrs.inject({}) { |h,s| k,v = s.split(/\=/, 2); h[k] = v; h }
616ebb8f » josevalim
2009-12-28 Remove unused code paths and require mail only when it's needed.
624 [ctype, {"charset" => @charset}.merge(attrs)]
971f4ff8 » josevalim
2009-12-27 DRY ActionMailer code.
625 end
15d7cac2 » mikel
2009-11-12 Starting again on actionmailer integration with mail
626 end
627
db045dbb » dhh
2004-11-24 Initial
628 end
629 end
Something went wrong with that request. Please try again.