cached_mailer 0.0.1.pre1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +15 -1
- data/VERSION +1 -1
- data/cached_mailer.gemspec +2 -2
- data/lib/action_mailer/cached_mailer.rb +7 -2
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Cached Mailer simply stores a copy of all the email you send with ActionMailer to the database. The template used is also stored so you can run queries on the database for specific emails.
|
4
4
|
|
5
|
-
Note: This gem was almost completely taken from ar_mailer.
|
5
|
+
Note: This gem was almost completely taken from ar_mailer. ARMailer basically does the same thing, but instead actually sends the emails at a later date. This doesn't work on Heroku or other environments where you can't run background executables, so cached_mailer simply stores the emails for record keeping purposes while also sending them the same way it always did.
|
6
6
|
|
7
7
|
== Installing Cached Mailer
|
8
8
|
|
@@ -45,6 +45,20 @@ Or specify a custom model name
|
|
45
45
|
|
46
46
|
Done! All the emails you send with ActionMailer will automagically be cached to the database for later reference.
|
47
47
|
|
48
|
+
== Storing Email Contents
|
49
|
+
|
50
|
+
By default cached_mailer does not store the encoded body of the email in the database. Emails can be long, and this is to make sure your database doesn't grow wildly out of control. If you really want to store the entire content of the emails, you can do so by adding this to an initializer:
|
51
|
+
|
52
|
+
ActionMailer::Base.cache_content = true
|
53
|
+
|
54
|
+
=== Alternate Mail Storage
|
55
|
+
|
56
|
+
By default cached_mailer assumes you are using an ActiveRecord model called
|
57
|
+
Email to store the emails created before sending. If you want to change
|
58
|
+
this you alter it in an intializer like so:
|
59
|
+
|
60
|
+
ActionMailer::Base.email_class = Newsletter
|
61
|
+
|
48
62
|
== Note on Patches/Pull Requests
|
49
63
|
|
50
64
|
* Fork the project.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.1.0
|
data/cached_mailer.gemspec
CHANGED
@@ -5,9 +5,9 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{cached_mailer}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.1.0"
|
9
9
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new("
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["mhodgson"]
|
12
12
|
s.date = %q{2009-12-12}
|
13
13
|
s.description = %q{Cached Mailer simply stores a copy of all the email you send with ActionMailer to the database. The template used is also stored so you can run queries on the database for specific emails.}
|
@@ -1,5 +1,8 @@
|
|
1
1
|
class ActionMailer::Base
|
2
|
-
|
2
|
+
|
3
|
+
@@cache_content = false
|
4
|
+
cattr_accessor :cache_content
|
5
|
+
|
3
6
|
@@email_class_name = 'Email'
|
4
7
|
|
5
8
|
def self.email_class=(klass)
|
@@ -12,7 +15,9 @@ class ActionMailer::Base
|
|
12
15
|
|
13
16
|
def deliver_with_cache!(mail)
|
14
17
|
mail.destinations.each do |destination|
|
15
|
-
|
18
|
+
mail_attributes = {:to => destination, :from => mail.from.first, :template => @template}
|
19
|
+
mail_attributes.merge!(:mail => mail.encoded) if cache_content
|
20
|
+
self.class.email_class.create mail_attributes
|
16
21
|
end
|
17
22
|
end
|
18
23
|
alias_method_chain :deliver!, :cache
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cached_mailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mhodgson
|
@@ -62,9 +62,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
62
62
|
version:
|
63
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
|
-
- - "
|
65
|
+
- - ">="
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version:
|
67
|
+
version: "0"
|
68
68
|
version:
|
69
69
|
requirements: []
|
70
70
|
|