From b8c46c86f0b785f6afc3c58eeb1b347543f5901e Mon Sep 17 00:00:00 2001 From: Cody Fauser Date: Wed, 14 May 2008 09:10:02 -0400 Subject: Improve and cleanup ActionMailer documentation --- actionmailer/README | 17 +++++++------- actionmailer/lib/action_mailer/base.rb | 42 +++++++++++++++++++--------------- 2 files changed, 32 insertions(+), 27 deletions(-) (limited to 'actionmailer') diff --git a/actionmailer/README b/actionmailer/README index d9012704ad..0e16ea6ec6 100755 --- a/actionmailer/README +++ b/actionmailer/README @@ -19,8 +19,7 @@ are all set up this way. An example of such a method: recipients recipient subject "[Signed up] Welcome #{recipient}" from "system@loudthinking.com" - - body(:recipient => recipient) + body :recipient => recipient end The body of the email is created by using an Action View template (regular @@ -91,13 +90,13 @@ a limited number of email. The Base class has the full list of configuration options. Here's an example: -ActionMailer::Base.smtp_settings = { - :address=>'smtp.yourserver.com', # default: localhost - :port=>'25', # default: 25 - :user_name=>'user', - :password=>'pass', - :authentication=>:plain # :plain, :login or :cram_md5 -} + ActionMailer::Base.smtp_settings = { + :address => 'smtp.yourserver.com', # default: localhost + :port => '25', # default: 25 + :user_name => 'user', + :password => 'pass', + :authentication => :plain # :plain, :login or :cram_md5 + } == Dependencies diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index a3762bf81b..908bd1c5f2 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -35,7 +35,7 @@ module ActionMailer #:nodoc: # * subject - The subject of your email. Sets the Subject: header. # * from - Who the email you are sending is from. Sets the From: header. # * cc - Takes one or more email addresses. These addresses will receive a carbon copy of your email. Sets the Cc: header. - # * bcc - Takes one or more email address. These addresses will receive a blind carbon copy of your email. Sets the Bcc header. + # * bcc - Takes one or more email address. These addresses will receive a blind carbon copy of your email. Sets the Bcc: header. # * sent_on - The date on which the message was sent. If not set, the header wil be set by the delivery agent. # * content_type - Specify the content type of the message. Defaults to text/plain. # * headers - Specify additional headers to be set for the message, e.g. headers 'X-Mail-Count' => 107370. @@ -127,11 +127,11 @@ module ActionMailer #:nodoc: # # class MyMailer < ActionMailer::Base # def signup_notification(recipient) - # recipients recipient.email_address_with_name - # subject "New account information" - # body "account" => recipient - # from "system@example.com" - # content_type "text/html" # Here's where the magic happens + # recipients recipient.email_address_with_name + # subject "New account information" + # from "system@example.com" + # body :account => recipient + # content_type "text/html" # end # end # @@ -145,6 +145,7 @@ module ActionMailer #:nodoc: # recipients recipient.email_address_with_name # subject "New account information" # from "system@example.com" + # content_type "multipart/alternative" # # part :content_type => "text/html", # :body => render_message("signup-as-html", :account => recipient) @@ -167,9 +168,14 @@ module ActionMailer #:nodoc: # * signup_notification.text.x-yaml.erb # # Each would be rendered and added as a separate part to the message, - # with the corresponding content type. The same body hash is passed to - # each template. + # with the corresponding content type. The content type for the entire + # message is automatically set to multipart/alternative, which indicates + # that the email contains multiple different representations of the same email + # body. The same body hash is passed to each template. # + # Implicit template rendering is not performed if any attachments or parts have been added to the email. + # This means that you'll have to manually add each part to the email and set the content type of the email + # to multipart/alternative. # # = Attachments # @@ -210,11 +216,11 @@ module ActionMailer #:nodoc: # * :user_name - If your mail server requires authentication, set the username in this setting. # * :password - If your mail server requires authentication, set the password in this setting. # * :authentication - If your mail server requires authentication, you need to specify the authentication type here. - # This is a symbol and one of :plain, :login, :cram_md5 + # This is a symbol and one of :plain, :login, :cram_md5. # - # * sendmail_settings - Allows you to override options for the :sendmail delivery method - # * :location - The location of the sendmail executable, defaults to "/usr/sbin/sendmail" - # * :arguments - The command line arguments + # * sendmail_settings - Allows you to override options for the :sendmail delivery method. + # * :location - The location of the sendmail executable. Defaults to /usr/sbin/sendmail. + # * :arguments - The command line arguments. Defaults to -i -t. # # * raise_delivery_errors - Whether or not errors should be raised if the email fails to be delivered. # @@ -227,16 +233,16 @@ module ActionMailer #:nodoc: # for unit and functional testing. # # * default_charset - The default charset used for the body and to encode the subject. Defaults to UTF-8. You can also - # pick a different charset from inside a method with @charset. + # pick a different charset from inside a method with +charset+. # * default_content_type - The default content type used for the main part of the message. Defaults to "text/plain". You - # can also pick a different content type from inside a method with @content_type. - # * default_mime_version - The default mime version used for the message. Defaults to "1.0". You - # can also pick a different value from inside a method with @mime_version. + # can also pick a different content type from inside a method with +content_type+. + # * default_mime_version - The default mime version used for the message. Defaults to 1.0. You + # can also pick a different value from inside a method with +mime_version+. # * default_implicit_parts_order - When a message is built implicitly (i.e. multiple parts are assembled from templates # which specify the content type in their filenames) this variable controls how the parts are ordered. Defaults to - # ["text/html", "text/enriched", "text/plain"]. Items that appear first in the array have higher priority in the mail client + # ["text/html", "text/enriched", "text/plain"]. Items that appear first in the array have higher priority in the mail client # and appear last in the mime encoded message. You can also pick a different order from inside a method with - # @implicit_parts_order. + # +implicit_parts_order+. class Base include AdvAttrAccessor, PartContainer include ActionController::UrlWriter if Object.const_defined?(:ActionController) -- cgit v1.2.3