mailhopper 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +4 -0
- data/lib/generators/mailhopper/templates/migrations/create_emails.rb +12 -4
- data/lib/mailhopper/queue.rb +13 -7
- data/lib/mailhopper/version.rb +1 -1
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/{20110801151741_create_emails.rb → 20110916191655_create_emails.rb} +11 -4
- data/test/dummy/db/schema.rb +4 -4
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +13 -0
- data/test/dummy/log/test.log +1584 -0
- data/test/unit/email_test.rb +66 -19
- metadata +6 -6
data/README.rdoc
CHANGED
@@ -7,8 +7,12 @@ Why use Mailhopper to queue your email?
|
|
7
7
|
* If email can't be delivered from your queue (e.g. your smtp server is down), you can retry delivery until successful.
|
8
8
|
* Emails can be accessed at any time, even after they've been sent.
|
9
9
|
|
10
|
+
The complete rationale is explained in this blog post: http://www.cerebris.com/blog/2011/09/07/tame-rails-email-dragons-with-mailhopper/
|
11
|
+
|
10
12
|
Mailhopper is intended to be used along with a delivery agent such as DelayedMailhopper, which uses DelayedJob to deliver email from the Mailhopper queue. Without a delivery agent, emails will accumulate in the Mailhopper queue but won't be delivered.
|
11
13
|
|
14
|
+
DelayedMailhopper can be found here: https://github.com/cerebris/delayed_mailhopper
|
15
|
+
|
12
16
|
== Requirements
|
13
17
|
|
14
18
|
Rails 3.1+
|
@@ -4,12 +4,20 @@ class CreateEmails < ActiveRecord::Migration
|
|
4
4
|
def self.up
|
5
5
|
create_table :emails do |t|
|
6
6
|
t.string :from_address, :null => false
|
7
|
-
|
7
|
+
|
8
|
+
t.string :reply_to_address,
|
9
|
+
:subject
|
10
|
+
|
11
|
+
# The following addresses have been defined as text fields to allow for multiple recipients. These fields could
|
12
|
+
# instead be defined as strings, and even indexed, if you'd like to improve search performance and you can
|
13
|
+
# confidently limit the size of their contents.
|
14
|
+
|
15
|
+
t.text :to_address,
|
8
16
|
:cc_address,
|
9
17
|
:bcc_address,
|
10
|
-
|
11
|
-
|
12
|
-
|
18
|
+
|
19
|
+
t.text :content
|
20
|
+
|
13
21
|
t.datetime :sent_at
|
14
22
|
t.timestamps
|
15
23
|
end
|
data/lib/mailhopper/queue.rb
CHANGED
@@ -5,14 +5,20 @@ module Mailhopper
|
|
5
5
|
|
6
6
|
def deliver!(mail)
|
7
7
|
Base.email_class.create({
|
8
|
-
:to_address
|
9
|
-
:from_address
|
10
|
-
:cc_address
|
11
|
-
:bcc_address
|
12
|
-
:reply_to_address => mail.reply_to
|
13
|
-
:subject
|
14
|
-
:content
|
8
|
+
:to_address => address_to_s(mail.to),
|
9
|
+
:from_address => address_to_s(mail.from),
|
10
|
+
:cc_address => address_to_s(mail.cc),
|
11
|
+
:bcc_address => address_to_s(mail.bcc),
|
12
|
+
:reply_to_address => address_to_s(mail.reply_to),
|
13
|
+
:subject => mail.subject,
|
14
|
+
:content => mail.to_s
|
15
15
|
})
|
16
16
|
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def address_to_s(field)
|
21
|
+
field.join(',') if field && !field.empty?
|
22
|
+
end
|
17
23
|
end
|
18
24
|
end
|
data/lib/mailhopper/version.rb
CHANGED
Binary file
|
data/test/dummy/db/migrate/{20110801151741_create_emails.rb → 20110916191655_create_emails.rb}
RENAMED
@@ -4,12 +4,19 @@ class CreateEmails < ActiveRecord::Migration
|
|
4
4
|
def self.up
|
5
5
|
create_table :emails do |t|
|
6
6
|
t.string :from_address, :null => false
|
7
|
-
|
7
|
+
|
8
|
+
t.string :reply_to_address,
|
9
|
+
:subject
|
10
|
+
|
11
|
+
# The following addresses have been defined as text fields to allow for multiple recipients. These fields could
|
12
|
+
# instead be defined as strings, and even indexed, if you'd like to improve search performance and you can
|
13
|
+
# confidently limit the size of their contents.
|
14
|
+
|
15
|
+
t.text :to_address,
|
8
16
|
:cc_address,
|
9
17
|
:bcc_address,
|
10
|
-
:
|
11
|
-
|
12
|
-
t.text :content
|
18
|
+
:content
|
19
|
+
|
13
20
|
t.datetime :sent_at
|
14
21
|
t.timestamps
|
15
22
|
end
|
data/test/dummy/db/schema.rb
CHANGED
@@ -10,15 +10,15 @@
|
|
10
10
|
#
|
11
11
|
# It's strongly recommended to check this file into your version control system.
|
12
12
|
|
13
|
-
ActiveRecord::Schema.define(:version =>
|
13
|
+
ActiveRecord::Schema.define(:version => 20110916191655) do
|
14
14
|
|
15
15
|
create_table "emails", :force => true do |t|
|
16
16
|
t.string "from_address", :null => false
|
17
|
-
t.string "to_address"
|
18
|
-
t.string "cc_address"
|
19
|
-
t.string "bcc_address"
|
20
17
|
t.string "reply_to_address"
|
21
18
|
t.string "subject"
|
19
|
+
t.text "to_address"
|
20
|
+
t.text "cc_address"
|
21
|
+
t.text "bcc_address"
|
22
22
|
t.text "content"
|
23
23
|
t.datetime "sent_at"
|
24
24
|
t.datetime "created_at"
|
data/test/dummy/db/test.sqlite3
CHANGED
Binary file
|
@@ -48,3 +48,16 @@ Migrating to CreateEmails (20110801151741)
|
|
48
48
|
[1m[36m (0.1ms)[0m [1mselect sqlite_version(*)[0m
|
49
49
|
[1m[35m (0.1ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
50
50
|
[1m[36m (0.0ms)[0m [1mPRAGMA index_list("emails")[0m
|
51
|
+
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
52
|
+
[1m[35m (2.4ms)[0m DROP TABLE "emails"
|
53
|
+
[1m[36m (1.1ms)[0m [1mDELETE FROM "schema_migrations" WHERE "schema_migrations"."version" = '20110801151741'[0m
|
54
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
55
|
+
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
56
|
+
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
57
|
+
Migrating to CreateEmails (20110916191655)
|
58
|
+
[1m[35m (0.0ms)[0m select sqlite_version(*)
|
59
|
+
[1m[36m (0.3ms)[0m [1mCREATE TABLE "emails" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "from_address" varchar(255) NOT NULL, "reply_to_address" varchar(255), "subject" varchar(255), "to_address" text, "cc_address" text, "bcc_address" text, "content" text, "sent_at" datetime, "created_at" datetime, "updated_at" datetime) [0m
|
60
|
+
[1m[35m (0.1ms)[0m INSERT INTO "schema_migrations" ("version") VALUES ('20110916191655')
|
61
|
+
[1m[36m (0.0ms)[0m [1mselect sqlite_version(*)[0m
|
62
|
+
[1m[35m (0.1ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
63
|
+
[1m[36m (0.0ms)[0m [1mPRAGMA index_list("emails")[0m
|