Skip to content
This repository
Newer
Older
100644 685 lines (603 sloc) 27.392 kb
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
1 require 'action_mailer/adv_attr_accessor'
2 require 'action_mailer/part'
5ddffc8c » jamis
2005-07-01 Allow for nested parts in multipart mails #1570 [Flurin Egger]
3 require 'action_mailer/part_container'
bde3df2b » jamis
2005-07-06 Correctly normalize newlines in outgoing emails before encoding the b…
4 require 'action_mailer/utils'
508c26c0 » jamis
2005-06-06 BCC headers are removed when sending via SMTP
5 require 'tmail/net'
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
6
c4590d57 » dhh
2006-03-28 Fixed docs
7 module ActionMailer #:nodoc:
98dc5827 » lifo
2008-05-25 Merge docrails.
8 # Action Mailer allows you to send email from your application using a mailer model and views.
db045dbb » dhh
2004-11-24 Initial
9 #
20bd4bd3 » dhh
2006-09-02 Updated docs and otherwise
10 #
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
11 # = Mailer Models
20bd4bd3 » dhh
2006-09-02 Updated docs and otherwise
12 #
98dc5827 » lifo
2008-05-25 Merge docrails.
13 # 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…
14 #
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
15 # $ script/generate mailer Notifier
16 #
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
17 # The generated model inherits from ActionMailer::Base. Emails are defined by creating methods within the model which are then
18 # 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, …
19 # to add attachments.
20 #
21 # Examples:
22 #
23 # class Notifier < ActionMailer::Base
24 # def signup_notification(recipient)
25 # recipients recipient.email_address_with_name
26 # from "system@example.com"
27 # subject "New account information"
20bd4bd3 » dhh
2006-09-02 Updated docs and otherwise
28 # body :account => recipient
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
29 # end
30 # end
31 #
32 # Mailer methods have the following configuration methods available.
33 #
34 # * <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.
35 # * <tt>subject</tt> - The subject of your email. Sets the <tt>Subject:</tt> header.
36 # * <tt>from</tt> - Who the email you are sending is from. Sets the <tt>From:</tt> header.
37 # * <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]
38 # * <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.
39 # * <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, …
40 # * <tt>sent_on</tt> - The date on which the message was sent. If not set, the header wil be set by the delivery agent.
41 # * <tt>content_type</tt> - Specify the content type of the message. Defaults to <tt>text/plain</tt>.
42 # * <tt>headers</tt> - Specify additional headers to be set for the message, e.g. <tt>headers 'X-Mail-Count' => 107370</tt>.
43 #
5c0d38f6 » dhh
2008-03-27 Fixed that a return-path header would be ignored (closes #7572) [joost]
44 # When a <tt>headers 'return-path'</tt> is specified, that value will be used as the 'envelope from'
45 # address. Setting this is useful when you want delivery notifications sent to a different address than
46 # the one in <tt>from</tt>.
47 #
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
48 # The <tt>body</tt> method has special behavior. It takes a hash which generates an instance variable
49 # named after each key in the hash containing the value that that key points to.
50 #
5c0d38f6 » dhh
2008-03-27 Fixed that a return-path header would be ignored (closes #7572) [joost]
51 # So, for example, <tt>body :account => recipient</tt> would result
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
52 # in an instance variable <tt>@account</tt> with the value of <tt>recipient</tt> being accessible in the
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
53 # view.
54 #
20bd4bd3 » dhh
2006-09-02 Updated docs and otherwise
55 #
56 # = Mailer views
57 #
98dc5827 » lifo
2008-05-25 Merge docrails.
58 # 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, …
59 # 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
60 # 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…
61 # 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
62 # <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, …
63 #
64 # Variables defined in the model are accessible as instance variables in the view.
65 #
66 # Emails by default are sent in plain text, so a sample view for our model example might look like this:
67 #
68 # Hi <%= @account.name %>,
69 # Thanks for joining our service! Please check back often.
70 #
20bd4bd3 » dhh
2006-09-02 Updated docs and otherwise
71 # You can even use Action Pack helpers in these views. For example:
72 #
73 # You got a new note!
74 # <%= truncate(note.body, 25) %>
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
75 #
20bd4bd3 » dhh
2006-09-02 Updated docs and otherwise
76 #
4809dcc1 » Cody Fauser
2008-04-21 * Remove default_url_options from mailer generator
77 # = Generating URLs
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
78 #
4809dcc1 » Cody Fauser
2008-04-21 * Remove default_url_options from mailer generator
79 # 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…
80 # Unlike controllers from Action Pack, the mailer instance doesn't have any context about the incoming request,
81 # so you'll need to provide all of the details needed to generate a URL.
20bd4bd3 » dhh
2006-09-02 Updated docs and otherwise
82 #
4809dcc1 » Cody Fauser
2008-04-21 * Remove default_url_options from mailer generator
83 # 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…
84 #
4809dcc1 » Cody Fauser
2008-04-21 * Remove default_url_options from mailer generator
85 # <%= url_for(:host => "example.com", :controller => "welcome", :action => "greeting") %>
20bd4bd3 » dhh
2006-09-02 Updated docs and otherwise
86 #
4809dcc1 » Cody Fauser
2008-04-21 * Remove default_url_options from mailer generator
87 # 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…
88 #
4809dcc1 » Cody Fauser
2008-04-21 * Remove default_url_options from mailer generator
89 # <%= users_url(:host => "example.com") %>
90 #
91 # You will want to avoid using the <tt>name_of_route_path</tt> form of named routes because it doesn't make sense to
92 # generate relative URLs in email messages.
93 #
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
94 # 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
95 # the <tt>ActionMailer::Base.default_url_options</tt> hash as follows:
96 #
97 # ActionMailer::Base.default_url_options[:host] = "example.com"
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
98 #
dc4eec11 » lifo
2008-05-09 Merge docrails:
99 # 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
100 #
101 # config.action_mailer.default_url_options = { :host => "example.com" }
20bd4bd3 » dhh
2006-09-02 Updated docs and otherwise
102 #
4809dcc1 » Cody Fauser
2008-04-21 * Remove default_url_options from mailer generator
103 # If you do decide to set a default <tt>:host</tt> for your mailers you will want to use the
104 # <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…
105 # 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
106 # explicitly provided.
20bd4bd3 » dhh
2006-09-02 Updated docs and otherwise
107 #
108 # = Sending mail
109 #
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
110 # 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, …
111 # for delivery later:
112 #
113 # Notifier.deliver_signup_notification(david) # sends the email
114 # mail = Notifier.create_signup_notification(david) # => a tmail object
115 # Notifier.deliver(mail)
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
116 #
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
117 # You never instantiate your mailer class. Rather, your delivery instance
118 # methods are automatically wrapped in class methods that start with the word
119 # <tt>deliver_</tt> followed by the name of the mailer method that you would
120 # like to deliver. The <tt>signup_notification</tt> method defined above is
121 # delivered by invoking <tt>Notifier.deliver_signup_notification</tt>.
122 #
20bd4bd3 » dhh
2006-09-02 Updated docs and otherwise
123 #
124 # = HTML email
125 #
21187c0f » dhh
2007-02-21 Apply the rest of Chads patch
126 # 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, …
127 # set the content type to html.
128 #
129 # class MyMailer < ActionMailer::Base
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
130 # def signup_notification(recipient)
46f30f90 » lifo
2008-05-16 Merge documentation changes from docrails.
131 # recipients recipient.email_address_with_name
132 # subject "New account information"
133 # from "system@example.com"
134 # body :account => recipient
135 # content_type "text/html"
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
136 # end
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
137 # end
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
138 #
20bd4bd3 » dhh
2006-09-02 Updated docs and otherwise
139 #
140 # = Multipart email
141 #
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
142 # You can explicitly specify multipart messages:
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
143 #
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
144 # class ApplicationMailer < ActionMailer::Base
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
145 # def signup_notification(recipient)
146 # recipients recipient.email_address_with_name
147 # subject "New account information"
148 # from "system@example.com"
46f30f90 » lifo
2008-05-16 Merge documentation changes from docrails.
149 # content_type "multipart/alternative"
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
150 #
151 # part :content_type => "text/html",
152 # :body => render_message("signup-as-html", :account => recipient)
153 #
154 # part "text/plain" do |p|
155 # p.body = render_message("signup-as-plain", :account => recipient)
156 # p.transfer_encoding = "base64"
157 # end
158 # end
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
159 # end
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
160 #
98dc5827 » lifo
2008-05-25 Merge docrails.
161 # 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, …
162 # detect and use multipart templates, where each template is named after the name of the action, followed
163 # 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…
164 #
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
165 # For example, if the following templates existed:
21187c0f » dhh
2007-02-21 Apply the rest of Chads patch
166 # * signup_notification.text.plain.erb
167 # * signup_notification.text.html.erb
168 # * signup_notification.text.xml.builder
169 # * signup_notification.text.x-yaml.erb
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
170 #
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
171 # Each would be rendered and added as a separate part to the message,
46f30f90 » lifo
2008-05-16 Merge documentation changes from docrails.
172 # with the corresponding content type. The content type for the entire
173 # message is automatically set to <tt>multipart/alternative</tt>, which indicates
174 # that the email contains multiple different representations of the same email
175 # 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…
176 #
46f30f90 » lifo
2008-05-16 Merge documentation changes from docrails.
177 # Implicit template rendering is not performed if any attachments or parts have been added to the email.
178 # This means that you'll have to manually add each part to the email and set the content type of the email
179 # to <tt>multipart/alternative</tt>.
20bd4bd3 » dhh
2006-09-02 Updated docs and otherwise
180 #
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
181 # = Attachments
20bd4bd3 » dhh
2006-09-02 Updated docs and otherwise
182 #
0a407bca » Marcel Molina
2006-05-10 ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, …
183 # Attachments can be added by using the +attachment+ method.
184 #
185 # Example:
186 #
187 # class ApplicationMailer < ActionMailer::Base
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
188 # # attachments
189 # def signup_notification(recipient)
190 # recipients recipient.email_address_with_name
191 # subject "New account information"
192 # from "system@example.com"
193 #
194 # attachment :content_type => "image/jpeg",
195 # :body => File.read("an-image.jpg")
196 #
197 # attachment "application/pdf" do |a|
198 # a.body = generate_your_pdf_here()
199 # end
db045dbb » dhh
2004-11-24 Initial
200 # end
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
201 # end
c927aa0f » dhh
2004-12-16 Updated documentation
202 #
20bd4bd3 » dhh
2006-09-02 Updated docs and otherwise
203 #
c927aa0f » dhh
2004-12-16 Updated documentation
204 # = Configuration options
205 #
206 # These options are specified on the class level, like <tt>ActionMailer::Base.template_root = "/my/templates"</tt>
207 #
64092de2 » fxn
2008-05-02 Improve documentation coverage and markup
208 # * <tt>template_root</tt> - Determines the base from which template references will be made.
c927aa0f » dhh
2004-12-16 Updated documentation
209 #
210 # * <tt>logger</tt> - the logger is used for generating information on the mailing run if available.
211 # Can be set to nil for no logging. Compatible with both Ruby's own Logger and Log4r loggers.
212 #
64092de2 » fxn
2008-05-02 Improve documentation coverage and markup
213 # * <tt>smtp_settings</tt> - Allows detailed configuration for <tt>:smtp</tt> delivery method:
dc4eec11 » lifo
2008-05-09 Merge docrails:
214 # * <tt>:address</tt> - Allows you to use a remote mail server. Just change it from its default "localhost" setting.
215 # * <tt>:port</tt> - On the off chance that your mail server doesn't run on port 25, you can change it.
216 # * <tt>:domain</tt> - If you need to specify a HELO domain, you can do it here.
217 # * <tt>:user_name</tt> - If your mail server requires authentication, set the username in this setting.
218 # * <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…
219 # * <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.
220 # This is a symbol and one of <tt>:plain</tt>, <tt>:login</tt>, <tt>:cram_md5</tt>.
c927aa0f » dhh
2004-12-16 Updated documentation
221 #
46f30f90 » lifo
2008-05-16 Merge documentation changes from docrails.
222 # * <tt>sendmail_settings</tt> - Allows you to override options for the <tt>:sendmail</tt> delivery method.
223 # * <tt>:location</tt> - The location of the sendmail executable. Defaults to <tt>/usr/sbin/sendmail</tt>.
224 # * <tt>:arguments</tt> - The command line arguments. Defaults to <tt>-i -t</tt>.
dc4eec11 » lifo
2008-05-09 Merge docrails:
225 #
226 # * <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
227 #
64092de2 » fxn
2008-05-02 Improve documentation coverage and markup
228 # * <tt>delivery_method</tt> - Defines a delivery method. Possible values are <tt>:smtp</tt> (default), <tt>:sendmail</tt>, and <tt>:test</tt>.
c927aa0f » dhh
2004-12-16 Updated documentation
229 #
dc4eec11 » lifo
2008-05-09 Merge docrails:
230 # * <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
231 # but this can be turned off to help functional testing.
232 #
64092de2 » fxn
2008-05-02 Improve documentation coverage and markup
233 # * <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
234 # for unit and functional testing.
af56c806 » dhh
2005-02-24 Updated documentation
235 #
b2504f8b » josh
2008-08-06 Tidy up ActionMailer rendering logic to take advantage of view path c…
236 # * <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.
237 # pick a different charset from inside a method with +charset+.
475bd741 » dhh
2005-10-26 Fix docs (closes #2598)
238 # * <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…
239 # can also pick a different content type from inside a method with +content_type+.
46f30f90 » lifo
2008-05-16 Merge documentation changes from docrails.
240 # * <tt>default_mime_version</tt> - The default mime version used for the message. Defaults to <tt>1.0</tt>. You
241 # can also pick a different value from inside a method with +mime_version+.
475bd741 » dhh
2005-10-26 Fix docs (closes #2598)
242 # * <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…
243 # 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.
244 # <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…
245 # 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.
246 # +implicit_parts_order+.
db045dbb » dhh
2004-11-24 Initial
247 class Base
0fe8e3d6 » dhh
2005-07-09 Added a config example in README #1626 [courtenay]
248 include AdvAttrAccessor, PartContainer
6228220c » dhh
2008-09-09 Revert "Revert "Add layout functionality to mailers.""
249 if Object.const_defined?(:ActionController)
250 include ActionController::UrlWriter
251 include ActionController::Layout
252 end
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
253
c927aa0f » dhh
2004-12-16 Updated documentation
254 private_class_method :new #:nodoc:
db045dbb » dhh
2004-11-24 Initial
255
cb21db1a » josh
2008-07-31 Treat ActionMailer template_root as a view path set internally to avo…
256 class_inheritable_accessor :view_paths
db045dbb » dhh
2004-11-24 Initial
257 cattr_accessor :logger
258
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
259 @@smtp_settings = {
260 :address => "localhost",
261 :port => 25,
262 :domain => 'localhost.localdomain',
263 :user_name => nil,
264 :password => nil,
db045dbb » dhh
2004-11-24 Initial
265 :authentication => nil
266 }
27bb903a » NZKoz
2007-01-31 Rename server_settings to smtp_settings, add sendmail_settings to all…
267 cattr_accessor :smtp_settings
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
268
27bb903a » NZKoz
2007-01-31 Rename server_settings to smtp_settings, add sendmail_settings to all…
269 @@sendmail_settings = {
270 :location => '/usr/sbin/sendmail',
271 :arguments => '-i -t'
272 }
273 cattr_accessor :sendmail_settings
db045dbb » dhh
2004-11-24 Initial
274
275 @@raise_delivery_errors = true
276 cattr_accessor :raise_delivery_errors
277
57cde631 » dhh
2007-11-07 Allow ActionMailer subclasses to individually set their delivery meth…
278 superclass_delegating_accessor :delivery_method
279 self.delivery_method = :smtp
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
280
db045dbb » dhh
2004-11-24 Initial
281 @@perform_deliveries = true
282 cattr_accessor :perform_deliveries
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
283
db045dbb » dhh
2004-11-24 Initial
284 @@deliveries = []
285 cattr_accessor :deliveries
286
3fad0cd0 » dhh
2005-02-19 Added support for charsets for both subject and body. The default cha…
287 @@default_charset = "utf-8"
288 cattr_accessor :default_charset
289
100fd726 » jamis
2005-06-03 Added a "content_type" accessor to allow messages to explicitly speci…
290 @@default_content_type = "text/plain"
291 cattr_accessor :default_content_type
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
292
45b5555f » jamis
2006-09-09 Make mime version default to 1.0. closes #2323
293 @@default_mime_version = "1.0"
dca4d4e8 » jamis
2005-08-22 Multipart messages specify a MIME-Version header automatically #2003
294 cattr_accessor :default_mime_version
100fd726 » jamis
2005-06-03 Added a "content_type" accessor to allow messages to explicitly speci…
295
5c981528 » jamis
2005-07-01 Better multipart support with implicit multipart/alternative and sort…
296 @@default_implicit_parts_order = [ "text/html", "text/enriched", "text/plain" ]
297 cattr_accessor :default_implicit_parts_order
298
28bf2fa0 » josh
2008-09-28 Protect body ivar from being clobbered by the mailer template assigns
299 cattr_reader :protected_instance_variables
300 @@protected_instance_variables = %w(@body)
301
59f1df1b » jamis
2005-10-16 Update/extend ActionMailer documentation (rdoc)
302 # Specify the BCC addresses for the message
303 adv_attr_accessor :bcc
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 # Define the body of the message. This is either a Hash (in which case it
306 # specifies the variables to pass to the template when it is rendered),
307 # or a string, in which case it specifies the actual text of the message.
308 adv_attr_accessor :body
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
309
59f1df1b » jamis
2005-10-16 Update/extend ActionMailer documentation (rdoc)
310 # Specify the CC addresses for the message.
311 adv_attr_accessor :cc
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 charset to use for the message. This defaults to the
314 # +default_charset+ specified for ActionMailer::Base.
315 adv_attr_accessor :charset
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
316
59f1df1b » jamis
2005-10-16 Update/extend ActionMailer documentation (rdoc)
317 # Specify the content type for the message. This defaults to <tt>text/plain</tt>
318 # in most cases, but can be automatically set in some situations.
319 adv_attr_accessor :content_type
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
320
59f1df1b » jamis
2005-10-16 Update/extend ActionMailer documentation (rdoc)
321 # Specify the from address for the message.
322 adv_attr_accessor :from
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
323
cf6299db » Adam
2008-05-23 Add ActionMailer#reply_to. [#245 state:resolved]
324 # Specify the address (if different than the "from" address) to direct
325 # replies to this message.
326 adv_attr_accessor :reply_to
327
59f1df1b » jamis
2005-10-16 Update/extend ActionMailer documentation (rdoc)
328 # Specify additional headers to be added to the message.
329 adv_attr_accessor :headers
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
330
59f1df1b » jamis
2005-10-16 Update/extend ActionMailer documentation (rdoc)
331 # Specify the order in which parts should be sorted, based on content-type.
332 # This defaults to the value for the +default_implicit_parts_order+.
333 adv_attr_accessor :implicit_parts_order
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
334
59f1df1b » jamis
2005-10-16 Update/extend ActionMailer documentation (rdoc)
335 # Defaults to "1.0", but may be explicitly given if needed.
336 adv_attr_accessor :mime_version
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 # The recipient addresses for the message, either as a string (for a single
339 # address) or an array (for multiple addresses).
340 adv_attr_accessor :recipients
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
341
59f1df1b » jamis
2005-10-16 Update/extend ActionMailer documentation (rdoc)
342 # The date on which the message was sent. If not set (the default), the
343 # header will be set by the delivery agent.
344 adv_attr_accessor :sent_on
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
345
59f1df1b » jamis
2005-10-16 Update/extend ActionMailer documentation (rdoc)
346 # Specify the subject of the message.
347 adv_attr_accessor :subject
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
348
59f1df1b » jamis
2005-10-16 Update/extend ActionMailer documentation (rdoc)
349 # Specify the template name to use for current message. This is the "base"
350 # template name, without the extension or directory, and may be used to
351 # have multiple mailer methods share the same template.
352 adv_attr_accessor :template
165097ed » dhh
2004-12-07 Added access to custom headers, like cc, bcc, and reply-to #268 [Andr…
353
bd5ed651 » technoweenie
2007-11-26 Update ActionMailer so it treats ActionView the same way that ActionC…
354 # Override the mailer name, which defaults to an inflected version of the
355 # mailer's class name. If you want to use a template in a non-standard
356 # location, you can use this to specify that location.
357 def mailer_name(value = nil)
358 if value
359 self.mailer_name = value
360 else
361 self.class.mailer_name
362 end
363 end
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
364
bd5ed651 » technoweenie
2007-11-26 Update ActionMailer so it treats ActionView the same way that ActionC…
365 def mailer_name=(value)
366 self.class.mailer_name = value
367 end
368
59f1df1b » jamis
2005-10-16 Update/extend ActionMailer documentation (rdoc)
369 # The mail object instance referenced by this mailer.
370 attr_reader :mail
6228220c » dhh
2008-09-09 Revert "Revert "Add layout functionality to mailers.""
371 attr_reader :template_name, :default_template_name, :action_name
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
372
eda17194 » jamis
2005-07-31 ActionMailer::Base.deliver(email) had been accidentally removed, but …
373 class << self
bd5ed651 » technoweenie
2007-11-26 Update ActionMailer so it treats ActionView the same way that ActionC…
374 attr_writer :mailer_name
375
376 def mailer_name
377 @mailer_name ||= name.underscore
378 end
379
380 # for ActionView compatibility
381 alias_method :controller_name, :mailer_name
382 alias_method :controller_path, :mailer_name
383
3cf773b1 » floehopper
2008-08-29 ActionMailer should respond_to? to methods handled by method_missing [#…
384 def respond_to?(method_symbol, include_private = false) #:nodoc:
385 matches_dynamic_method?(method_symbol) || super
386 end
387
388 def method_missing(method_symbol, *parameters) #:nodoc:
389 match = matches_dynamic_method?(method_symbol)
390 case match[1]
391 when 'create' then new(match[2], *parameters).mail
392 when 'deliver' then new(match[2], *parameters).deliver!
393 when 'new' then nil
eda17194 » jamis
2005-07-31 ActionMailer::Base.deliver(email) had been accidentally removed, but …
394 else super
395 end
396 end
397
59f1df1b » jamis
2005-10-16 Update/extend ActionMailer documentation (rdoc)
398 # Receives a raw email, parses it into an email object, decodes it,
399 # instantiates a new mailer, and passes the email object to the mailer
98dc5827 » lifo
2008-05-25 Merge docrails.
400 # object's +receive+ method. If you want your mailer to be able to
401 # process incoming messages, you'll need to implement a +receive+
59f1df1b » jamis
2005-10-16 Update/extend ActionMailer documentation (rdoc)
402 # method that accepts the email object as a parameter:
403 #
404 # class MyMailer < ActionMailer::Base
405 # def receive(mail)
406 # ...
407 # end
408 # end
409 def receive(raw_email)
eda17194 » jamis
2005-07-31 ActionMailer::Base.deliver(email) had been accidentally removed, but …
410 logger.info "Received mail:\n #{raw_email}" unless logger.nil?
411 mail = TMail::Mail.parse(raw_email)
412 mail.base64_decode
413 new.receive(mail)
414 end
415
416 # Deliver the given mail object directly. This can be used to deliver
417 # a preconstructed mail object, like:
418 #
419 # email = MyMailer.create_some_mail(parameters)
420 # email.set_some_obscure_header "frobnicate"
421 # MyMailer.deliver(email)
422 def deliver(mail)
423 new.deliver!(mail)
424 end
271404e8 » jeremy
2007-06-07 Register alternative template engines using ActionMailer::Base.regist…
425
426 def register_template_extension(extension)
b2504f8b » josh
2008-08-06 Tidy up ActionMailer rendering logic to take advantage of view path c…
427 ActiveSupport::Deprecation.warn(
428 "ActionMailer::Base.register_template_extension has been deprecated." +
429 "Use ActionView::Base.register_template_extension instead", caller)
271404e8 » jeremy
2007-06-07 Register alternative template engines using ActionMailer::Base.regist…
430 end
61c90a4a » NZKoz
2008-01-21 Reapply the TemplateFinder first applied in [8669] then reverted in […
431
cb21db1a » josh
2008-07-31 Treat ActionMailer template_root as a view path set internally to avo…
432 def template_root
433 self.view_paths && self.view_paths.first
434 end
435
61c90a4a » NZKoz
2008-01-21 Reapply the TemplateFinder first applied in [8669] then reverted in […
436 def template_root=(root)
cb21db1a » josh
2008-07-31 Treat ActionMailer template_root as a view path set internally to avo…
437 self.view_paths = ActionView::Base.process_view_paths(root)
61c90a4a » NZKoz
2008-01-21 Reapply the TemplateFinder first applied in [8669] then reverted in […
438 end
3cf773b1 » floehopper
2008-08-29 ActionMailer should respond_to? to methods handled by method_missing [#…
439
440 private
441 def matches_dynamic_method?(method_name) #:nodoc:
442 method_name = method_name.to_s
443 /(create|deliver)_([_a-z]\w*)/.match(method_name) || /^(new)$/.match(method_name)
444 end
eda17194 » jamis
2005-07-31 ActionMailer::Base.deliver(email) had been accidentally removed, but …
445 end
446
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
447 # Instantiate a new mailer object. If +method_name+ is not +nil+, the mailer
448 # will be initialized according to the named method. If not, the mailer will
449 # remain uninitialized (useful when you only need to invoke the "receive"
450 # method, for instance).
2789b5d2 » dhh
2005-07-06 Tuned documentation for release (AM)
451 def initialize(method_name=nil, *parameters) #:nodoc:
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
452 create!(method_name, *parameters) if method_name
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
453 end
454
455 # Initialize the mailer via the given +method_name+. The body will be
456 # rendered and a new TMail::Mail object created.
2789b5d2 » dhh
2005-07-06 Tuned documentation for release (AM)
457 def create!(method_name, *parameters) #:nodoc:
f474f337 » jamis
2005-08-22 Move mailer initialization to a separate (overridable) method, so tha…
458 initialize_defaults(method_name)
c3ff04b0 » jeremy
2006-11-13 Allow mailer actions named send by using __send__ internally. Closes #…
459 __send__(method_name, *parameters)
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
460
461 # If an explicit, textual body has not been set, we check assumptions.
462 unless String === @body
463 # First, we look to see if there are any likely templates that match,
464 # which include the content-type in their file name (i.e.,
21187c0f » dhh
2007-02-21 Apply the rest of Chads patch
465 # "the_template_file.text.html.erb", etc.). Only do this if parts
dca4d4e8 » jamis
2005-08-22 Multipart messages specify a MIME-Version header automatically #2003
466 # have not already been specified manually.
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
467 if @parts.empty?
b2504f8b » josh
2008-08-06 Tidy up ActionMailer rendering logic to take advantage of view path c…
468 Dir.glob("#{template_path}/#{@template}.*").each do |path|
469 template = template_root["#{mailer_name}/#{File.basename(path)}"]
470
471 # Skip unless template has a multipart format
f3f7d166 » macksmind
2008-09-04 Fixed problem causes by leftover backup templates ending in tilde [st…
472 next unless template && template.multipart?
b2504f8b » josh
2008-08-06 Tidy up ActionMailer rendering logic to take advantage of view path c…
473
474 @parts << Part.new(
475 :content_type => template.content_type,
476 :disposition => "inline",
477 :charset => charset,
478 :body => render_message(template, @body)
479 )
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
480 end
5c981528 » jamis
2005-07-01 Better multipart support with implicit multipart/alternative and sort…
481 unless @parts.empty?
482 @content_type = "multipart/alternative"
483 @parts = sort_parts(@parts, @implicit_parts_order)
484 end
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
485 end
db045dbb » dhh
2004-11-24 Initial
486
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
487 # Then, if there were such templates, we check to see if we ought to
488 # also render a "normal" template (without the content type). If a
489 # normal template exists (or if there were no implicit parts) we render
490 # it.
04248c62 » josh
2008-08-13 Ensure templates are rendered if all the parts are already processed
491 template_exists = @parts.empty?
492 template_exists ||= template_root["#{mailer_name}/#{@template}"]
493 @body = render_message(@template, @body) if template_exists
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
494
495 # Finally, if there are other message parts and a textual body exists,
496 # we shift it onto the front of the parts and set the body to nil (so
497 # that create_mail doesn't try to render it in addition to the parts).
498 if !@parts.empty? && String === @body
499 @parts.unshift Part.new(:charset => charset, :body => @body)
500 @body = nil
425aa50a » dhh
2005-03-20 Added receiver method for incoming email
501 end
db045dbb » dhh
2004-11-24 Initial
502 end
503
dca4d4e8 » jamis
2005-08-22 Multipart messages specify a MIME-Version header automatically #2003
504 # If this is a multipart e-mail add the mime_version if it is not
505 # already set.
506 @mime_version ||= "1.0" if !@parts.empty?
507
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
508 # build the mail object itself
509 @mail = create_mail
510 end
db045dbb » dhh
2004-11-24 Initial
511
eda17194 » jamis
2005-07-31 ActionMailer::Base.deliver(email) had been accidentally removed, but …
512 # Delivers a TMail::Mail object. By default, it delivers the cached mail
98dc5827 » lifo
2008-05-25 Merge docrails.
513 # 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 …
514 # no alternate has been given as the parameter, this will fail.
59f1df1b » jamis
2005-10-16 Update/extend ActionMailer documentation (rdoc)
515 def deliver!(mail = @mail)
eda17194 » jamis
2005-07-31 ActionMailer::Base.deliver(email) had been accidentally removed, but …
516 raise "no mail object available for delivery!" unless mail
fbd3eb71 » jeremy
2008-02-02 Less verbose mail logging: just recipients for :info log level; the w…
517 unless logger.nil?
be364551 » jeremy
2008-03-31 Ruby 1.9 compat: use Array() instead of #to_a.
518 logger.info "Sent mail to #{Array(recipients).join(', ')}"
fbd3eb71 » jeremy
2008-02-02 Less verbose mail logging: just recipients for :info log level; the w…
519 logger.debug "\n#{mail.encoded}"
520 end
256e800a » dhh
2005-04-11 Fixed quoting for all address headers, not just to #955 [Jamis Buck] …
521
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
522 begin
c3ff04b0 » jeremy
2006-11-13 Allow mailer actions named send by using __send__ internally. Closes #…
523 __send__("perform_delivery_#{delivery_method}", mail) if perform_deliveries
12ff554c » jeremy
2006-08-31 Tighten rescue clauses. Closes #5985.
524 rescue Exception => e # Net::SMTP errors or sendmail pipe errors
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
525 raise e if raise_delivery_errors
526 end
3fad0cd0 » dhh
2005-02-19 Added support for charsets for both subject and body. The default cha…
527
eda17194 » jamis
2005-07-31 ActionMailer::Base.deliver(email) had been accidentally removed, but …
528 return mail
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
529 end
3fad0cd0 » dhh
2005-02-19 Added support for charsets for both subject and body. The default cha…
530
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
531 private
f474f337 » jamis
2005-08-22 Move mailer initialization to a separate (overridable) method, so tha…
532 # Set up the default values for the various instance variables of this
533 # mailer. Subclasses may override this method to provide different
534 # defaults.
535 def initialize_defaults(method_name)
95e8740f » dhh
2005-10-26 Allow Mailers to have custom initialize methods that set default inst…
536 @charset ||= @@default_charset.dup
537 @content_type ||= @@default_content_type.dup
538 @implicit_parts_order ||= @@default_implicit_parts_order.dup
539 @template ||= method_name
6228220c » dhh
2008-09-09 Revert "Revert "Add layout functionality to mailers.""
540 @default_template_name = @action_name = @template
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
541 @mailer_name ||= self.class.name.underscore
95e8740f » dhh
2005-10-26 Allow Mailers to have custom initialize methods that set default inst…
542 @parts ||= []
543 @headers ||= {}
544 @body ||= {}
dca4d4e8 » jamis
2005-08-22 Multipart messages specify a MIME-Version header automatically #2003
545 @mime_version = @@default_mime_version.dup if @@default_mime_version
f474f337 » jamis
2005-08-22 Move mailer initialization to a separate (overridable) method, so tha…
546 end
547
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
548 def render_message(method_name, body)
74612273 » josh
2008-07-19 Ruby 1.9: Call join on template_root instead of to_s
549 render :file => method_name, :body => body
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
550 end
ae1e8520 » jamis
2005-08-22 Add a unified render method to ActionMailer (delegates to ActionView:…
551
552 def render(opts)
553 body = opts.delete(:body)
b2504f8b » josh
2008-08-06 Tidy up ActionMailer rendering logic to take advantage of view path c…
554 if opts[:file] && (opts[:file] !~ /\// && !opts[:file].respond_to?(:render))
bd5ed651 » technoweenie
2007-11-26 Update ActionMailer so it treats ActionView the same way that ActionC…
555 opts[:file] = "#{mailer_name}/#{opts[:file]}"
556 end
6228220c » dhh
2008-09-09 Revert "Revert "Add layout functionality to mailers.""
557
558 begin
559 old_template, @template = @template, initialize_template_class(body)
560 layout = respond_to?(:pick_layout, true) ? pick_layout(opts) : false
561 @template.render(opts.merge(:layout => layout))
562 ensure
563 @template = old_template
564 end
565 end
566
567 def default_template_format
568 :html
569 end
570
571 def candidate_for_layout?(options)
572 !@template.send(:_exempt_from_layout?, default_template_name)
ae1e8520 » jamis
2005-08-22 Add a unified render method to ActionMailer (delegates to ActionView:…
573 end
574
cb21db1a » josh
2008-07-31 Treat ActionMailer template_root as a view path set internally to avo…
575 def template_root
576 self.class.template_root
577 end
578
579 def template_root=(root)
580 self.class.template_root = root
581 end
582
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
583 def template_path
e23156e8 » josh
2008-07-19 Only create a path for ActionMailer template root instead of a path s…
584 "#{template_root}/#{mailer_name}"
db045dbb » dhh
2004-11-24 Initial
585 end
586
5ec990af » jamis
2005-06-16 Helper support for ActionMailer
587 def initialize_template_class(assigns)
cb21db1a » josh
2008-07-31 Treat ActionMailer template_root as a view path set internally to avo…
588 ActionView::Base.new(view_paths, assigns, self)
5ec990af » jamis
2005-06-16 Helper support for ActionMailer
589 end
590
5c981528 » jamis
2005-07-01 Better multipart support with implicit multipart/alternative and sort…
591 def sort_parts(parts, order = [])
592 order = order.collect { |s| s.downcase }
593
594 parts = parts.sort do |a, b|
595 a_ct = a.content_type.downcase
596 b_ct = b.content_type.downcase
597
598 a_in = order.include? a_ct
599 b_in = order.include? b_ct
600
601 s = case
602 when a_in && b_in
603 order.index(a_ct) <=> order.index(b_ct)
604 when a_in
605 -1
606 when b_in
607 1
608 else
609 a_ct <=> b_ct
610 end
611
612 # reverse the ordering because parts that come last are displayed
613 # first in mail clients
614 (s * -1)
615 end
616
617 parts
618 end
619
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
620 def create_mail
621 m = TMail::Mail.new
74a612c4 » dhh
2005-05-02 Added that delivery errors are caught in a way so the mail is still r…
622
cf6299db » Adam
2008-05-23 Add ActionMailer#reply_to. [#245 state:resolved]
623 m.subject, = quote_any_if_necessary(charset, subject)
624 m.to, m.from = quote_any_address_if_necessary(charset, recipients, from)
625 m.bcc = quote_address_if_necessary(bcc, charset) unless bcc.nil?
626 m.cc = quote_address_if_necessary(cc, charset) unless cc.nil?
627 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
628 m.mime_version = mime_version unless mime_version.nil?
cf6299db » Adam
2008-05-23 Add ActionMailer#reply_to. [#245 state:resolved]
629 m.date = sent_on.to_time rescue sent_on if sent_on
630
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
631 headers.each { |k, v| m[k] = v }
db045dbb » dhh
2004-11-24 Initial
632
db0e8ff1 » jamis
2006-03-18 Parse content-type apart before using it so that sub-parts of the hea…
633 real_content_type, ctype_attrs = parse_content_type
634
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
635 if @parts.empty?
db0e8ff1 » jamis
2006-03-18 Parse content-type apart before using it so that sub-parts of the hea…
636 m.set_content_type(real_content_type, nil, ctype_attrs)
bde3df2b » jamis
2005-07-06 Correctly normalize newlines in outgoing emails before encoding the b…
637 m.body = Utils.normalize_new_lines(body)
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
638 else
639 if String === body
640 part = TMail::Mail.new
bde3df2b » jamis
2005-07-06 Correctly normalize newlines in outgoing emails before encoding the b…
641 part.body = Utils.normalize_new_lines(body)
db0e8ff1 » jamis
2006-03-18 Parse content-type apart before using it so that sub-parts of the hea…
642 part.set_content_type(real_content_type, nil, ctype_attrs)
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
643 part.set_content_disposition "inline"
644 m.parts << part
645 end
3fad0cd0 » dhh
2005-02-19 Added support for charsets for both subject and body. The default cha…
646
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
647 @parts.each do |p|
648 part = (TMail::Mail === p ? p : p.to_mail(self))
649 m.parts << part
650 end
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
651
49efa02b » jamis
2006-03-19 Nil charset caused subject line to be improperly quoted in implicitly…
652 if real_content_type =~ /multipart/
653 ctype_attrs.delete "charset"
654 m.set_content_type(real_content_type, nil, ctype_attrs)
655 end
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
656 end
256e800a » dhh
2005-04-11 Fixed quoting for all address headers, not just to #955 [Jamis Buck] …
657
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
658 @mail = m
256e800a » dhh
2005-04-11 Fixed quoting for all address headers, not just to #955 [Jamis Buck] …
659 end
660
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
661 def perform_delivery_smtp(mail)
508c26c0 » jamis
2005-06-06 BCC headers are removed when sending via SMTP
662 destinations = mail.destinations
663 mail.ready_to_send
5c0d38f6 » dhh
2008-03-27 Fixed that a return-path header would be ignored (closes #7572) [joost]
664 sender = mail['return-path'] || mail.from
508c26c0 » jamis
2005-06-06 BCC headers are removed when sending via SMTP
665
3b0e1d90 » josh
2008-05-14 Prefer string core_ext inflector methods over directly accessing Infl…
666 Net::SMTP.start(smtp_settings[:address], smtp_settings[:port], smtp_settings[:domain],
416091d8 » NZKoz
2007-01-31 Fix missed smtp_session changes to base.rb.
667 smtp_settings[:user_name], smtp_settings[:password], smtp_settings[:authentication]) do |smtp|
5c0d38f6 » dhh
2008-03-27 Fixed that a return-path header would be ignored (closes #7572) [joost]
668 smtp.sendmail(mail.encoded, sender, destinations)
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
669 end
256e800a » dhh
2005-04-11 Fixed quoting for all address headers, not just to #955 [Jamis Buck] …
670 end
671
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
672 def perform_delivery_sendmail(mail)
77730f7c » NZKoz
2008-04-05 Avoid modifying the sendmail_settings hash when using the return path…
673 sendmail_args = sendmail_settings[:arguments]
674 sendmail_args += " -f \"#{mail['return-path']}\"" if mail['return-path']
675 IO.popen("#{sendmail_settings[:location]} #{sendmail_args}","w+") do |sm|
bb62568c » dhh
2005-07-17 Fix problem with sendmail delivery where headers should be delimited …
676 sm.print(mail.encoded.gsub(/\r/, ''))
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
677 sm.flush
256e800a » dhh
2005-04-11 Fixed quoting for all address headers, not just to #955 [Jamis Buck] …
678 end
679 end
680
359caef3 » jamis
2005-05-29 A very thorough refactoring, resulting in new mail property setters a…
681 def perform_delivery_test(mail)
682 deliveries << mail
683 end
db045dbb » dhh
2004-11-24 Initial
684 end
685 end
Something went wrong with that request. Please try again.