| Start | ||||
|---|---|---|---|---|
| Basic Mailer This example uses four different files:
In this case, the user model calls the user_mailer.rbuser.rbapproved.html.erbapproved.text.erb |
||||
| Generating a new mailer To generate a new mailer, enter the following command This will generate a blank template file in Two layout files will also be generated for the email view, one for the html format and one for the text format. If you prefer not to use the generator, you can create your own mailers. Make sure they inherit from |
||||
| Adding Attachments
By default, attachments will be encoded with You can also add inline attachments |
||||
| ActionMailer Callbacks ActionMailer supports three callbacks
Provide these in your Mailer class Then create these methods under the |
||||
| ActionMailer Interceptor Action Mailer provides hooks into the interceptor methods. These allow you to register classes that are called during the mail delivery life cycle. An interceptor class must implement the :delivering_email(message) method which will be called before the email is sent, allowing you to make modifications to the email before it hits the delivery agents. Your class should make any needed modifications directly to the passed in Mail::Message instance. It can be useful for developers to send email to themselves not real users. Example of registering an actionmailer interceptor: |
||||
| Generate a Scheduled Newsletter Create the Newsletter model: Create the Newsletter controller: After that, change the create.html.erb view to the nex name. We will convert this file to and partial view which will be stored inside the Footer. The name will be _form.html.erb. | Change name file from: | To: | |---|---|---|---|---|---|---|---|---|---app/views/**newsletters/create.html.erb** | app/views/**newsletters/_form.html.erb** |
Read Article
https://develop.horje.com/learn/1434/reference