Skip to content
This repository
Browse code

Improve and cleanup ActionMailer documentation

  • Loading branch information...
commit b8c46c86f0b785f6afc3c58eeb1b347543f5901e 1 parent f4aaa2e
Cody Fauser authored May 14, 2008
17  actionmailer/README
@@ -19,8 +19,7 @@ are all set up this way. An example of such a method:
19 19
     recipients recipient
20 20
     subject    "[Signed up] Welcome #{recipient}"
21 21
     from       "system@loudthinking.com"
22  
-
23  
-    body(:recipient => recipient)
  22
+    body       :recipient => recipient
24 23
   end
25 24
 
26 25
 The body of the email is created by using an Action View template (regular
@@ -91,13 +90,13 @@ a limited number of email.
91 90
 
92 91
 The Base class has the full list of configuration options. Here's an example:
93 92
 
94  
-ActionMailer::Base.smtp_settings = {
95  
-  :address=>'smtp.yourserver.com',    # default: localhost
96  
-  :port=>'25',                        # default: 25
97  
-  :user_name=>'user',
98  
-  :password=>'pass',
99  
-  :authentication=>:plain             # :plain, :login or :cram_md5
100  
-}
  93
+  ActionMailer::Base.smtp_settings = {
  94
+    :address        => 'smtp.yourserver.com', # default: localhost
  95
+    :port           => '25',                  # default: 25
  96
+    :user_name      => 'user',
  97
+    :password       => 'pass',
  98
+    :authentication => :plain                 # :plain, :login or :cram_md5
  99
+  }
101 100
 
102 101
 == Dependencies
103 102
 
42  actionmailer/lib/action_mailer/base.rb
@@ -35,7 +35,7 @@ module ActionMailer #:nodoc:
35 35
   # * <tt>subject</tt> - The subject of your email. Sets the <tt>Subject:</tt> header.
36 36
   # * <tt>from</tt> - Who the email you are sending is from. Sets the <tt>From:</tt> header.
37 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.
38  
-  # * <tt>bcc</tt> - Takes one or more email address. These addresses will receive a blind carbon copy of your email. Sets the <tt>Bcc</tt> header.
  38
+  # * <tt>bcc</tt> - Takes one or more email address. These addresses will receive a blind carbon copy of your email. Sets the <tt>Bcc:</tt> header.
39 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 40
   # * <tt>content_type</tt> - Specify the content type of the message. Defaults to <tt>text/plain</tt>.
41 41
   # * <tt>headers</tt> - Specify additional headers to be set for the message, e.g. <tt>headers 'X-Mail-Count' => 107370</tt>.
@@ -127,11 +127,11 @@ module ActionMailer #:nodoc:
127 127
   #
128 128
   #   class MyMailer < ActionMailer::Base
129 129
   #     def signup_notification(recipient)
130  
-  #       recipients recipient.email_address_with_name
131  
-  #       subject    "New account information"
132  
-  #       body       "account" => recipient
133  
-  #       from       "system@example.com"
134  
-  #       content_type "text/html"   #    Here's where the magic happens
  130
+  #       recipients   recipient.email_address_with_name
  131
+  #       subject      "New account information"
  132
+  #       from         "system@example.com"
  133
+  #       body         :account => recipient
  134
+  #       content_type "text/html"
135 135
   #     end
136 136
   #   end  
137 137
   #
@@ -145,6 +145,7 @@ module ActionMailer #:nodoc:
145 145
   #       recipients      recipient.email_address_with_name
146 146
   #       subject         "New account information"
147 147
   #       from            "system@example.com"
  148
+  #       content_type    "multipart/alternative"
148 149
   #
149 150
   #       part :content_type => "text/html",
150 151
   #         :body => render_message("signup-as-html", :account => recipient)
@@ -167,9 +168,14 @@ module ActionMailer #:nodoc:
167 168
   # * signup_notification.text.x-yaml.erb
168 169
   #  
169 170
   # Each would be rendered and added as a separate part to the message,
170  
-  # with the corresponding content type. The same body hash is passed to
171  
-  # each template.
  171
+  # with the corresponding content type. The content type for the entire
  172
+  # message is automatically set to <tt>multipart/alternative</tt>, which indicates
  173
+  # that the email contains multiple different representations of the same email
  174
+  # body. The same body hash is passed to each template.
172 175
   #
  176
+  # Implicit template rendering is not performed if any attachments or parts have been added to the email.
  177
+  # This means that you'll have to manually add each part to the email and set the content type of the email
  178
+  # to <tt>multipart/alternative</tt>.
173 179
   #
174 180
   # = Attachments
175 181
   #
@@ -210,11 +216,11 @@ module ActionMailer #:nodoc:
210 216
   #   * <tt>:user_name</tt> - If your mail server requires authentication, set the username in this setting.
211 217
   #   * <tt>:password</tt> - If your mail server requires authentication, set the password in this setting.
212 218
   #   * <tt>:authentication</tt> - If your mail server requires authentication, you need to specify the authentication type here. 
213  
-  #     This is a symbol and one of <tt>:plain</tt>, <tt>:login</tt>, <tt>:cram_md5</tt>
  219
+  #     This is a symbol and one of <tt>:plain</tt>, <tt>:login</tt>, <tt>:cram_md5</tt>.
214 220
   #
215  
-  # * <tt>sendmail_settings</tt> - Allows you to override options for the <tt>:sendmail</tt> delivery method
216  
-  #   * <tt>:location</tt> - The location of the sendmail executable, defaults to "/usr/sbin/sendmail"
217  
-  #   * <tt>:arguments</tt> - The command line arguments
  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>.
218 224
   #
219 225
   # * <tt>raise_delivery_errors</tt> - Whether or not errors should be raised if the email fails to be delivered.
220 226
   #
@@ -227,16 +233,16 @@ module ActionMailer #:nodoc:
227 233
   #   for unit and functional testing.
228 234
   #
229 235
   # * <tt>default_charset</tt> - The default charset used for the body and to encode the subject. Defaults to UTF-8. You can also 
230  
-  #   pick a different charset from inside a method with <tt>@charset</tt>.
  236
+  #   pick a different charset from inside a method with +charset+.
231 237
   # * <tt>default_content_type</tt> - The default content type used for the main part of the message. Defaults to "text/plain". You
232  
-  #   can also pick a different content type from inside a method with <tt>@content_type</tt>. 
233  
-  # * <tt>default_mime_version</tt> - The default mime version used for the message. Defaults to "1.0". You
234  
-  #   can also pick a different value from inside a method with <tt>@mime_version</tt>.
  238
+  #   can also pick a different content type from inside a method with +content_type+. 
  239
+  # * <tt>default_mime_version</tt> - The default mime version used for the message. Defaults to <tt>1.0</tt>. You
  240
+  #   can also pick a different value from inside a method with +mime_version+.
235 241
   # * <tt>default_implicit_parts_order</tt> - When a message is built implicitly (i.e. multiple parts are assembled from templates
236 242
   #   which specify the content type in their filenames) this variable controls how the parts are ordered. Defaults to
237  
-  #   ["text/html", "text/enriched", "text/plain"]. Items that appear first in the array have higher priority in the mail client
  243
+  #   <tt>["text/html", "text/enriched", "text/plain"]</tt>. Items that appear first in the array have higher priority in the mail client
238 244
   #   and appear last in the mime encoded message. You can also pick a different order from inside a method with
239  
-  #   <tt>@implicit_parts_order</tt>.
  245
+  #   +implicit_parts_order+.
240 246
   class Base
241 247
     include AdvAttrAccessor, PartContainer
242 248
     include ActionController::UrlWriter if Object.const_defined?(:ActionController)

0 notes on commit b8c46c8

Please sign in to comment.
Something went wrong with that request. Please try again.