mailhopper 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
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
- t.string :to_address,
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
- :reply_to_address,
11
- :subject
12
- t.text :content
18
+
19
+ t.text :content
20
+
13
21
  t.datetime :sent_at
14
22
  t.timestamps
15
23
  end
@@ -5,14 +5,20 @@ module Mailhopper
5
5
 
6
6
  def deliver!(mail)
7
7
  Base.email_class.create({
8
- :to_address => mail.to.to_s,
9
- :from_address => mail.from.to_s,
10
- :cc_address => mail.cc.to_s,
11
- :bcc_address => mail.bcc.to_s,
12
- :reply_to_address => mail.reply_to.to_s,
13
- :subject => mail.subject,
14
- :content => mail.to_s
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
@@ -1,3 +1,3 @@
1
1
  module Mailhopper
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
Binary file
@@ -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
- t.string :to_address,
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
- :reply_to_address,
11
- :subject
12
- t.text :content
18
+ :content
19
+
13
20
  t.datetime :sent_at
14
21
  t.timestamps
15
22
  end
@@ -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 => 20110801151741) do
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"
Binary file
@@ -48,3 +48,16 @@ Migrating to CreateEmails (20110801151741)
48
48
   (0.1ms) select sqlite_version(*)
49
49
   (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
50
50
   (0.0ms) PRAGMA index_list("emails")
51
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
52
+  (2.4ms) DROP TABLE "emails"
53
+  (1.1ms) DELETE FROM "schema_migrations" WHERE "schema_migrations"."version" = '20110801151741'
54
+  (0.1ms) select sqlite_version(*)
55
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
56
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
57
+ Migrating to CreateEmails (20110916191655)
58
+  (0.0ms) select sqlite_version(*)
59
+  (0.3ms) CREATE 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) 
60
+  (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES ('20110916191655')
61
+  (0.0ms) select sqlite_version(*)
62
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
63
+  (0.0ms) PRAGMA index_list("emails")