You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: guides/source/action_mailer_basics.md
+19-10Lines changed: 19 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,10 @@ After reading this guide, you will know:
17
17
Introduction
18
18
------------
19
19
20
-
Action Mailer allows you to send emails from your application using mailer classes and views. Mailers work very similarly to controllers. They inherit from `ActionMailer::Base` and live in `app/mailers`, and they have associated views that appear in `app/views`.
20
+
Action Mailer allows you to send emails from your application using mailer classes
21
+
and views. Mailers work very similarly to controllers. They inherit from
22
+
`ActionMailer::Base` and live in `app/mailers`, and they have associated views
23
+
that appear in `app/views`.
21
24
22
25
Sending Emails
23
26
--------------
@@ -84,8 +87,11 @@ Here is a quick explanation of the items presented in the preceding method. For
84
87
a full list of all available options, please have a look further down at the
85
88
Complete List of Action Mailer user-settable attributes section.
86
89
87
-
*`default Hash` - This is a hash of default values for any email you send from this mailer. In this case we are setting the `:from` header to a value for all messages in this class. This can be overridden on a per-email basis.
88
-
*`mail` - The actual email message, we are passing the `:to` and `:subject` headers in.
90
+
*`default Hash` - This is a hash of default values for any email you send from
91
+
this mailer. In this case we are setting the `:from` header to a value for all
92
+
messages in this class. This can be overridden on a per-email basis.
93
+
*`mail` - The actual email message, we are passing the `:to` and `:subject`
94
+
headers in.
89
95
90
96
Just like controllers, any instance variables we define in the method become
91
97
available for use in the views.
@@ -151,7 +157,7 @@ $ bin/rake db:migrate
151
157
```
152
158
153
159
Now that we have a user model to play with, we will just edit the
154
-
`app/controllers/users_controller.rb` make it instruct the UserMailer to deliver
160
+
`app/controllers/users_controller.rb` make it instruct the `UserMailer` to deliver
155
161
an email to the newly created user by editing the create action and inserting a
156
162
call to `UserMailer.welcome_email` right after the user is successfully saved:
157
163
@@ -230,9 +236,11 @@ different, encode your content and pass in the encoded content and encoding in a
|`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.|
611
-
|`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><li>`:enable_starttls_auto`-Set this to `false`if there is a problem with your server certificate that you cannot resolve.</li></ul>|
619
+
|`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><li>`:enable_starttls_auto`-Set this to `false`if there is a problem with your server certificate that you cannot resolve.</li></ul>|
612
620
|`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>|
613
621
|`raise_delivery_errors`|Whetherornot errors should be raised if the email fails to be delivered. This only works if the external email server is configured for immediate delivery.|
614
622
|`delivery_method`|Defines a delivery method. Possible values are:<ul><li>`:smtp` (default), can be configured by using`config.action_mailer.smtp_settings`.</li><li>`:sendmail`, can be configured by using`config.action_mailer.sendmail_settings`.</li><li>`:file`: save emails to files; can be configured by using`config.action_mailer.file_settings`.</li><li>`:test`: save emails to `ActionMailer::Base.deliveries` array.</li></ul>See [API docs](http://api.rubyonrails.org/classes/ActionMailer/Base.html) for more info.|
0 commit comments