| Class | ActionMailer::Base |
| In: |
vendor/actionmailer/lib/action_mailer/base.rb
|
| Parent: | Object |
Usage:
class ApplicationMailer < ActionMailer::Base
def post_notification(recipients, post)
@recipients = recipients
@from = post.author.email_address_with_name
@headers["bcc"] = SYSTEM_ADMINISTRATOR_EMAIL
@headers["reply-to"] = "notifications@example.com"
@subject = "[#{post.account.name} #{post.title}]"
@body["post"] = post
end
def comment_notification(recipient, comment)
@recipients = recipient.email_address_with_name
@subject = "[#{comment.post.project.client.firm.account.name}]" +
" Re: #{comment.post.title}"
@body["comment"] = comment
@from = comment.author.email_address_with_name
@sent_on = comment.posted_on
end
end
# After this post_notification will look for "templates/application_mailer/post_notification.rhtml"
ApplicationMailer.template_root = "templates"
ApplicationMailer.create_comment_notification(david, hello_world) # => a tmail object
ApplicationMailer.deliver_comment_notification(david, hello_world) # sends the email
These options are specified on the class level, like ActionMailer::Base.template_root = "/my/templates"
pick a different charset from inside a method with <tt>@encoding</tt>.
| bcc | [RW] | |
| body | [RW] | |
| cc | [RW] | |
| charset | [RW] | |
| encode_subject | [RW] | |
| from | [RW] | |
| headers | [RW] | |
| recipients | [RW] | |
| sent_on | [RW] | |
| subject | [RW] |