mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
mailer guide: fixes indentation, and use fixed width fonts wherever necessary
This commit is contained in:
parent
cc90adfd2a
commit
129ad7226d
1 changed files with 26 additions and 31 deletions
|
@ -48,10 +48,8 @@ class UserMailer < ActionMailer::Base
|
||||||
def welcome_email(user)
|
def welcome_email(user)
|
||||||
@user = user
|
@user = user
|
||||||
@url = "http://example.com/login"
|
@url = "http://example.com/login"
|
||||||
mail(:to => user.email,
|
mail(:to => user.email, :subject => "Welcome to My Awesome Site")
|
||||||
:subject => "Welcome to My Awesome Site")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
</ruby>
|
</ruby>
|
||||||
|
|
||||||
|
@ -142,11 +140,11 @@ end
|
||||||
|
|
||||||
This provides a much simpler implementation that does not require the registering of observers and the like.
|
This provides a much simpler implementation that does not require the registering of observers and the like.
|
||||||
|
|
||||||
The method +welcome_email+ returns a Mail::Message object which can then just be told +deliver+ to send itself out.
|
The method +welcome_email+ returns a <tt>Mail::Message</tt> object which can then just be told +deliver+ to send itself out.
|
||||||
|
|
||||||
NOTE: In previous versions of Rails, you would call +deliver_welcome_email+ or +create_welcome_email+. This has been deprecated in Rails 3.0 in favour of just calling the method name itself.
|
NOTE: In previous versions of Rails, you would call +deliver_welcome_email+ or +create_welcome_email+. This has been deprecated in Rails 3.0 in favour of just calling the method name itself.
|
||||||
|
|
||||||
WARNING: Sending out one email should only take a fraction of a second, if you are planning on sending out many emails, or you have a slow domain resolution service, you might want to investigate using a background process like delayed job.
|
WARNING: Sending out an email should only take a fraction of a second, but if you are planning on sending out many emails, or you have a slow domain resolution service, you might want to investigate using a background process like Delayed Job.
|
||||||
|
|
||||||
h4. Auto encoding header values
|
h4. Auto encoding header values
|
||||||
|
|
||||||
|
@ -267,8 +265,7 @@ to format the email address in the format <tt>"Name <email>"</tt>.
|
||||||
def welcome_email(user)
|
def welcome_email(user)
|
||||||
@user = user
|
@user = user
|
||||||
email_with_name = "#{@user.name} <#{@user.email}>"
|
email_with_name = "#{@user.name} <#{@user.email}>"
|
||||||
mail(:to => email_with_name,
|
mail(:to => email_with_name, :subject => "Welcome to My Awesome Site")
|
||||||
:subject => "Welcome to My Awesome Site")
|
|
||||||
end
|
end
|
||||||
</ruby>
|
</ruby>
|
||||||
|
|
||||||
|
@ -291,8 +288,6 @@ class UserMailer < ActionMailer::Base
|
||||||
:template_name => 'another')
|
:template_name => 'another')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
|
||||||
</ruby>
|
</ruby>
|
||||||
|
|
||||||
In this case it will look for templates at +app/views/notifications+ with name +another+.
|
In this case it will look for templates at +app/views/notifications+ with name +another+.
|
||||||
|
@ -461,14 +456,14 @@ h3. Action Mailer Configuration
|
||||||
|
|
||||||
The following configuration options are best made in one of the environment files (environment.rb, production.rb, etc...)
|
The following configuration options are best made in one of the environment files (environment.rb, production.rb, etc...)
|
||||||
|
|
||||||
|template_root|Determines the base from which template references will be made.|
|
|+template_root+|Determines the base from which template references will be made.|
|
||||||
|logger|Generates information on the mailing run if available. Can be set to nil for no logging. Compatible with both Ruby's own Logger and Log4r loggers.|
|
|+logger+|Generates information on the mailing run if available. Can be set to +nil+ for no logging. Compatible with both Ruby's own +Logger+ and +Log4r+ loggers.|
|
||||||
|smtp_settings|Allows detailed configuration for :smtp delivery method:<ul><li>:address - Allows you to use a remote mail server. Just change it from its default "localhost" setting.</li><li>:port - On the off chance that your mail server doesn't run on port 25, you can change it.</li><li>:domain - If you need to specify a HELO domain, you can do it here.</li><li>:user_name - If your mail server requires authentication, set the username in this setting.</li><li>:password - If your mail server requires authentication, set the password in this setting.</li><li>: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.</li></ul>|
|
|+smtp_settings+|Allows detailed configuration for <tt>:smtp</tt> delivery method:<ul><li><tt>:address</tt> - Allows you to use a remote mail server. Just change it from its default "localhost" setting.</li><li><tt>:port</tt> - On the off chance that your mail server doesn't run on port 25, you can change it.</li><li><tt>:domain</tt> - If you need to specify a HELO domain, you can do it here.</li><li><tt>:user_name</tt> - If your mail server requires authentication, set the username in this setting.</li><li><tt>:password</tt> - If your mail server requires authentication, set the password in this setting.</li><li><tt>:authentication</tt> - If your mail server requires authentication, you need to specify the authentication type here. This is a symbol and one of <tt>:plain</tt>, <tt>:login</tt>, <tt>:cram_md5</tt>.</li></ul>|
|
||||||
|sendmail_settings|Allows you to override options for the :sendmail delivery method.<ul><li>:location - The location of the sendmail executable. Defaults to /usr/sbin/sendmail.</li><li>:arguments - The command line arguments to be passed to sendmail. Defaults to -i -t.</li></ul>|
|
|+sendmail_settings+|Allows you to override options for the <tt>:sendmail</tt> delivery method.<ul><li><tt>:location</tt> - The location of the sendmail executable. Defaults to <tt>/usr/sbin/sendmail</tt>.</li><li><tt>:arguments</tt> - The command line arguments to be passed to sendmail. Defaults to <tt>-i -t</tt>.</li></ul>|
|
||||||
|raise_delivery_errors|Whether or not errors should be raised if the email fails to be delivered.|
|
|+raise_delivery_errors+|Whether or not errors should be raised if the email fails to be delivered.|
|
||||||
|delivery_method|Defines a delivery method. Possible values are :smtp (default), :sendmail, :file and :test.|
|
|+delivery_method+|Defines a delivery method. Possible values are <tt>:smtp</tt> (default), <tt>:sendmail</tt>, <tt>:file</tt> and <tt>:test</tt>.|
|
||||||
|perform_deliveries|Determines whether deliveries are actually carried out when the +deliver+ method is invoked on the Mail message. By default they are, but this can be turned off to help functional testing.|
|
|+perform_deliveries+|Determines whether deliveries are actually carried out when the +deliver+ method is invoked on the Mail message. By default they are, but this can be turned off to help functional testing.|
|
||||||
|deliveries|Keeps an array of all the emails sent out through the Action Mailer with delivery_method :test. Most useful for unit and functional testing.|
|
|+deliveries+|Keeps an array of all the emails sent out through the Action Mailer with delivery_method :test. Most useful for unit and functional testing.|
|
||||||
|
|
||||||
h4. Example Action Mailer Configuration
|
h4. Example Action Mailer Configuration
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue