Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

root/tags/rel_0-9-4-1/actionmailer/README

Revision 4, 3.2 kB (checked in by david, 4 years ago)

Initial

  • Property svn:executable set to *
Line 
1 = Action Mailer -- Easy email delivery and testing
2
3 Action Mailer is framework for designing email-service layers. These layers
4 are used to consolidate code for sending out forgotten passwords, welcoming
5 wishes on signup, invoices for billing, and any other use case that requires
6 a written notification to either a person or another system.
7
8 The framework works by setting up all the email details, except the body,
9 in methods on the service layer. Subject, recipients, sender, and timestamp
10 are all set up this way. An example of such a method:
11
12   def signed_up(recipient)
13     @recipients   = recipient
14     @subject      = "[Signed up] Welcome #{recipient}"
15     @from         = "system@loudthinking.com"
16     @sent_on      = Time.local(2004, 12, 12)
17
18     @body["recipient"] = recipient
19   end
20
21 The body of the email is created by using an Action View template (regular
22 ERb) that has the content of the @body hash available as instance variables.
23 So the corresponding body template for the method above could look like this:
24
25   Hello there,
26
27   Mr. <%= @recipient %>
28  
29 And if the recipient was given as "david@loudthinking.com", the email
30 generated would look like this:
31
32   Date: Sun, 12 Dec 2004 00:00:00 +0100
33   From: system@loudthinking.com
34   To: david@loudthinking.com
35   Subject: [Signed up] Welcome david@loudthinking.com
36
37   Hello there,
38
39   Mr. david@loudthinking.com
40
41 You never actually call the instance methods like signed_up directly. Instead,
42 you call class methods like deliver_* and create_* that are automatically
43 created for each instance method. So if the signed_up method sat on
44 ApplicationMailer, it would look like this:
45
46   ApplicationMailer.create_signed_up("david@loudthinking.com")  # => tmail object for testing
47   ApplicationMailer.deliver_signed_up("david@loudthinking.com") # sends the email
48   ApplicationMailer.new.signed_up("david@loudthinking.com")     # won't work!
49
50
51 == Dependencies
52
53 Action Mailer requires that the Action Pack is either available to be required immediately
54 or is accessible as a GEM.
55
56
57 == Bundled software
58
59 * tmail 0.10.8 by Minero Aoki released under LGPL
60   Read more on http://i.loveruby.net/en/prog/tmail.html
61
62 * Text::Format 0.63 by Austin Ziegler released under OpenSource
63   Read more on http://www.halostatue.ca/ruby/Text__Format.html
64
65
66 == Download
67
68 The latest version of Action Mailer can be found at
69
70 * http://rubyforge.org/project/showfiles.php?group_id=361
71
72 Documentation can be found at
73
74 * http://actionmailer.rubyonrails.org
75
76
77 == Installation
78
79 You can install Action Mailer with the following command.
80
81   % [sudo] ruby install.rb
82
83 from its distribution directory.
84
85
86 == License
87
88 Action Mailer is released under the MIT license.
89
90
91 == Support
92
93 The Action Mailer homepage is http://actionmailer.rubyonrails.org. You can find
94 the Action Mailer RubyForge page at http://rubyforge.org/projects/actionmailer.
95 And as Jim from Rake says:
96
97    Feel free to submit commits or feature requests.  If you send a patch,
98    remember to update the corresponding unit tests.  If fact, I prefer
99    new feature to be submitted in the form of new unit tests.
100
101 For other information, feel free to ask on the ruby-talk mailing list (which
102 is mirrored to comp.lang.ruby) or contact mailto:david@loudthinking.com.
Note: See TracBrowser for help on using the browser.