mailhopper 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,5 +15,31 @@ module Mailhopper
15
15
  self.sent_at = Time.now
16
16
  self.save!
17
17
  end
18
+
19
+ class << self
20
+ def create_from_mail(mail)
21
+ create({
22
+ :to_address => address_to_s(mail.to),
23
+ :from_address => address_to_s(mail.from),
24
+ :cc_address => address_to_s(mail.cc),
25
+ :bcc_address => address_to_s(mail.bcc),
26
+ :reply_to_address => address_to_s(mail.reply_to),
27
+ :subject => mail.subject,
28
+ :content => mail.to_s
29
+ })
30
+ end
31
+
32
+ private
33
+
34
+ def address_to_s(field)
35
+ if field
36
+ if field.is_a?(Array)
37
+ field.join(',') unless field.empty?
38
+ else
39
+ field
40
+ end
41
+ end
42
+ end
43
+ end
18
44
  end
19
45
  end
@@ -4,27 +4,7 @@ module Mailhopper
4
4
  end
5
5
 
6
6
  def deliver!(mail)
7
- Base.email_class.create({
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
- })
7
+ Base.email_class.create_from_mail(mail)
16
8
  end
17
-
18
- private
19
-
20
- def address_to_s(field)
21
- if field
22
- if field.is_a?(Array)
23
- field.join(',') unless field.empty?
24
- else
25
- field
26
- end
27
- end
28
- end
29
9
  end
30
10
  end
@@ -1,3 +1,3 @@
1
1
  module Mailhopper
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -629,3 +629,195 @@ Papaya
629
629
   (0.1ms) SELECT COUNT(*) FROM "emails"
630
630
  Mailhopper::Email Load (0.2ms) SELECT "emails".* FROM "emails" ORDER BY created_at DESC LIMIT 1
631
631
   (0.5ms) rollback transaction
632
+  (0.4ms) begin transaction
633
+  (0.1ms) rollback transaction
634
+  (0.0ms) begin transaction
635
+  (0.1ms) SELECT COUNT(*) FROM "emails"
636
+ Rendered sample_mailer/hello.text.erb (24.5ms)
637
+  (0.1ms) SAVEPOINT active_record_1
638
+ SQL (22.5ms) INSERT INTO "emails" ("bcc_address", "cc_address", "content", "created_at", "from_address", "reply_to_address", "sent_at", "subject", "to_address", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["bcc_address", "bcc@example.com"], ["cc_address", "cc@example.com"], ["content", "Date: Mon, 07 May 2012 22:01:07 -0400\r\nFrom: from@example.com\r\nReply-To: reply_to@example.com\r\nTo: to@example.com\r\nCc: cc@example.com\r\nMessage-ID: <4fa87e636cb2a_11fdf3fc045c34cdc317a7@dgmpro.local.mail>\r\nSubject: Hiya!\r\nMime-Version: 1.0\r\nContent-Type: text/plain;\r\n charset=UTF-8\r\nContent-Transfer-Encoding: 7bit\r\n\r\nPapaya"], ["created_at", Tue, 08 May 2012 02:01:07 UTC +00:00], ["from_address", "from@example.com"], ["reply_to_address", "reply_to@example.com"], ["sent_at", nil], ["subject", "Hiya!"], ["to_address", "to@example.com"], ["updated_at", Tue, 08 May 2012 02:01:07 UTC +00:00]]
639
+  (0.0ms) RELEASE SAVEPOINT active_record_1
640
+
641
+ Sent mail to to@example.com (75ms)
642
+ Date: Mon, 07 May 2012 22:01:07 -0400
643
+ From: from@example.com
644
+ Reply-To: reply_to@example.com
645
+ To: to@example.com
646
+ Cc: cc@example.com
647
+ Message-ID: <4fa87e636cb2a_11fdf3fc045c34cdc317a7@dgmpro.local.mail>
648
+ Subject: Hiya!
649
+ Mime-Version: 1.0
650
+ Content-Type: text/plain;
651
+ charset=UTF-8
652
+ Content-Transfer-Encoding: 7bit
653
+
654
+ Papaya
655
+  (0.1ms) SELECT COUNT(*) FROM "emails"
656
+ Mailhopper::Email Load (0.2ms) SELECT "emails".* FROM "emails" ORDER BY created_at DESC LIMIT 1
657
+  (0.5ms) rollback transaction
658
+  (0.0ms) begin transaction
659
+  (0.1ms) SELECT COUNT(*) FROM "emails"
660
+ Rendered sample_mailer/hello.text.erb (0.1ms)
661
+  (0.1ms) SAVEPOINT active_record_1
662
+ SQL (0.4ms) INSERT INTO "emails" ("bcc_address", "cc_address", "content", "created_at", "from_address", "reply_to_address", "sent_at", "subject", "to_address", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["bcc_address", "bcc1@example.com,bcc2@example.com"], ["cc_address", "cc1@example.com,cc2@example.com"], ["content", "Date: Mon, 07 May 2012 22:01:07 -0400\r\nFrom: from1@example.com\r\nReply-To: reply_to@example.com\r\nTo: to1@example.com, \r\n to2@example.com\r\nCc: cc1@example.com, \r\n cc2@example.com\r\nMessage-ID: <4fa87e6379368_11fdf3fc045c34cdc31889@dgmpro.local.mail>\r\nSubject: Hiya!\r\nMime-Version: 1.0\r\nContent-Type: text/plain;\r\n charset=UTF-8\r\nContent-Transfer-Encoding: 7bit\r\n\r\nPapaya"], ["created_at", Tue, 08 May 2012 02:01:07 UTC +00:00], ["from_address", "from1@example.com"], ["reply_to_address", "reply_to@example.com"], ["sent_at", nil], ["subject", "Hiya!"], ["to_address", "to1@example.com,to2@example.com"], ["updated_at", Tue, 08 May 2012 02:01:07 UTC +00:00]]
663
+  (0.0ms) RELEASE SAVEPOINT active_record_1
664
+
665
+ Sent mail to to1@example.com, to2@example.com (12ms)
666
+ Date: Mon, 07 May 2012 22:01:07 -0400
667
+ From: from1@example.com
668
+ Reply-To: reply_to@example.com
669
+ To: to1@example.com,
670
+ to2@example.com
671
+ Cc: cc1@example.com,
672
+ cc2@example.com
673
+ Message-ID: <4fa87e6379368_11fdf3fc045c34cdc31889@dgmpro.local.mail>
674
+ Subject: Hiya!
675
+ Mime-Version: 1.0
676
+ Content-Type: text/plain;
677
+ charset=UTF-8
678
+ Content-Transfer-Encoding: 7bit
679
+
680
+ Papaya
681
+  (0.1ms) SELECT COUNT(*) FROM "emails"
682
+ Mailhopper::Email Load (0.2ms) SELECT "emails".* FROM "emails" ORDER BY created_at DESC LIMIT 1
683
+  (0.5ms) rollback transaction
684
+  (0.0ms) begin transaction
685
+  (0.1ms) SELECT COUNT(*) FROM "emails"
686
+ Rendered sample_mailer/hello.text.erb (0.1ms)
687
+  (0.1ms) SAVEPOINT active_record_1
688
+ SQL (0.4ms) INSERT INTO "emails" ("bcc_address", "cc_address", "content", "created_at", "from_address", "reply_to_address", "sent_at", "subject", "to_address", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["bcc_address", nil], ["cc_address", nil], ["content", "Date: Mon, 07 May 2012 22:01:07 -0400\r\nFrom: from@example.com\r\nTo: to@example.com\r\nMessage-ID: <4fa87e637dc85_11fdf3fc045c34cdc31955@dgmpro.local.mail>\r\nSubject: Hiya!\r\nMime-Version: 1.0\r\nContent-Type: text/plain;\r\n charset=UTF-8\r\nContent-Transfer-Encoding: 7bit\r\n\r\nPapaya"], ["created_at", Tue, 08 May 2012 02:01:07 UTC +00:00], ["from_address", "from@example.com"], ["reply_to_address", nil], ["sent_at", nil], ["subject", "Hiya!"], ["to_address", "to@example.com"], ["updated_at", Tue, 08 May 2012 02:01:07 UTC +00:00]]
689
+  (0.0ms) RELEASE SAVEPOINT active_record_1
690
+
691
+ Sent mail to to@example.com (10ms)
692
+ Date: Mon, 07 May 2012 22:01:07 -0400
693
+ From: from@example.com
694
+ To: to@example.com
695
+ Message-ID: <4fa87e637dc85_11fdf3fc045c34cdc31955@dgmpro.local.mail>
696
+ Subject: Hiya!
697
+ Mime-Version: 1.0
698
+ Content-Type: text/plain;
699
+ charset=UTF-8
700
+ Content-Transfer-Encoding: 7bit
701
+
702
+ Papaya
703
+  (0.1ms) SELECT COUNT(*) FROM "emails"
704
+ Mailhopper::Email Load (0.2ms) SELECT "emails".* FROM "emails" ORDER BY created_at DESC LIMIT 1
705
+  (0.5ms) rollback transaction
706
+  (0.0ms) begin transaction
707
+  (0.1ms) SELECT COUNT(*) FROM "emails"
708
+ Rendered sample_mailer/hello.text.erb (0.1ms)
709
+  (0.1ms) SAVEPOINT active_record_1
710
+ SQL (0.4ms) INSERT INTO "emails" ("bcc_address", "cc_address", "content", "created_at", "from_address", "reply_to_address", "sent_at", "subject", "to_address", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["bcc_address", nil], ["cc_address", nil], ["content", "Date: Mon, 07 May 2012 22:01:07 -0400\r\nfrom: from.@example.com\r\nto: to.@example.com\r\nMessage-ID: <4fa87e6382491_11fdf3fc045c34cdc32045@dgmpro.local.mail>\r\nSubject: Hiya!\r\nMime-Version: 1.0\r\nContent-Type: text/plain;\r\n charset=UTF-8\r\nContent-Transfer-Encoding: 7bit\r\n\r\nPapaya"], ["created_at", Tue, 08 May 2012 02:01:07 UTC +00:00], ["from_address", "from.@example.com"], ["reply_to_address", nil], ["sent_at", nil], ["subject", "Hiya!"], ["to_address", "to.@example.com"], ["updated_at", Tue, 08 May 2012 02:01:07 UTC +00:00]]
711
+  (0.0ms) RELEASE SAVEPOINT active_record_1
712
+
713
+ Sent mail to to.@example.com (7ms)
714
+ Date: Mon, 07 May 2012 22:01:07 -0400
715
+ from: from.@example.com
716
+ to: to.@example.com
717
+ Message-ID: <4fa87e6382491_11fdf3fc045c34cdc32045@dgmpro.local.mail>
718
+ Subject: Hiya!
719
+ Mime-Version: 1.0
720
+ Content-Type: text/plain;
721
+ charset=UTF-8
722
+ Content-Transfer-Encoding: 7bit
723
+
724
+ Papaya
725
+  (0.1ms) SELECT COUNT(*) FROM "emails"
726
+ Mailhopper::Email Load (0.2ms) SELECT "emails".* FROM "emails" ORDER BY created_at DESC LIMIT 1
727
+  (0.5ms) rollback transaction
728
+  (0.4ms) begin transaction
729
+  (0.1ms) rollback transaction
730
+  (0.0ms) begin transaction
731
+  (0.1ms) SELECT COUNT(*) FROM "emails"
732
+ Rendered sample_mailer/hello.text.erb (2.0ms)
733
+  (0.1ms) SAVEPOINT active_record_1
734
+ SQL (31.1ms) INSERT INTO "emails" ("bcc_address", "cc_address", "content", "created_at", "from_address", "reply_to_address", "sent_at", "subject", "to_address", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["bcc_address", "bcc@example.com"], ["cc_address", "cc@example.com"], ["content", "Date: Mon, 07 May 2012 22:22:42 -0400\r\nFrom: from@example.com\r\nReply-To: reply_to@example.com\r\nTo: to@example.com\r\nCc: cc@example.com\r\nMessage-ID: <4fa883727e9b_120dc3fdc91834cdc40222@dgmpro.local.mail>\r\nSubject: Hiya!\r\nMime-Version: 1.0\r\nContent-Type: text/plain;\r\n charset=UTF-8\r\nContent-Transfer-Encoding: 7bit\r\n\r\nPapaya"], ["created_at", Tue, 08 May 2012 02:22:42 UTC +00:00], ["from_address", "from@example.com"], ["reply_to_address", "reply_to@example.com"], ["sent_at", nil], ["subject", "Hiya!"], ["to_address", "to@example.com"], ["updated_at", Tue, 08 May 2012 02:22:42 UTC +00:00]]
735
+  (0.0ms) RELEASE SAVEPOINT active_record_1
736
+
737
+ Sent mail to to@example.com (80ms)
738
+ Date: Mon, 07 May 2012 22:22:42 -0400
739
+ From: from@example.com
740
+ Reply-To: reply_to@example.com
741
+ To: to@example.com
742
+ Cc: cc@example.com
743
+ Message-ID: <4fa883727e9b_120dc3fdc91834cdc40222@dgmpro.local.mail>
744
+ Subject: Hiya!
745
+ Mime-Version: 1.0
746
+ Content-Type: text/plain;
747
+ charset=UTF-8
748
+ Content-Transfer-Encoding: 7bit
749
+
750
+ Papaya
751
+  (0.1ms) SELECT COUNT(*) FROM "emails"
752
+ Mailhopper::Email Load (0.2ms) SELECT "emails".* FROM "emails" ORDER BY created_at DESC LIMIT 1
753
+  (0.5ms) rollback transaction
754
+  (0.1ms) begin transaction
755
+  (0.1ms) SELECT COUNT(*) FROM "emails"
756
+ Rendered sample_mailer/hello.text.erb (0.1ms)
757
+  (0.1ms) SAVEPOINT active_record_1
758
+ SQL (0.5ms) INSERT INTO "emails" ("bcc_address", "cc_address", "content", "created_at", "from_address", "reply_to_address", "sent_at", "subject", "to_address", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["bcc_address", "bcc1@example.com,bcc2@example.com"], ["cc_address", "cc1@example.com,cc2@example.com"], ["content", "Date: Mon, 07 May 2012 22:22:42 -0400\r\nFrom: from1@example.com\r\nReply-To: reply_to@example.com\r\nTo: to1@example.com, \r\n to2@example.com\r\nCc: cc1@example.com, \r\n cc2@example.com\r\nMessage-ID: <4fa88372165c1_120dc3fdc91834cdc403a@dgmpro.local.mail>\r\nSubject: Hiya!\r\nMime-Version: 1.0\r\nContent-Type: text/plain;\r\n charset=UTF-8\r\nContent-Transfer-Encoding: 7bit\r\n\r\nPapaya"], ["created_at", Tue, 08 May 2012 02:22:42 UTC +00:00], ["from_address", "from1@example.com"], ["reply_to_address", "reply_to@example.com"], ["sent_at", nil], ["subject", "Hiya!"], ["to_address", "to1@example.com,to2@example.com"], ["updated_at", Tue, 08 May 2012 02:22:42 UTC +00:00]]
759
+  (0.0ms) RELEASE SAVEPOINT active_record_1
760
+
761
+ Sent mail to to1@example.com, to2@example.com (12ms)
762
+ Date: Mon, 07 May 2012 22:22:42 -0400
763
+ From: from1@example.com
764
+ Reply-To: reply_to@example.com
765
+ To: to1@example.com,
766
+ to2@example.com
767
+ Cc: cc1@example.com,
768
+ cc2@example.com
769
+ Message-ID: <4fa88372165c1_120dc3fdc91834cdc403a@dgmpro.local.mail>
770
+ Subject: Hiya!
771
+ Mime-Version: 1.0
772
+ Content-Type: text/plain;
773
+ charset=UTF-8
774
+ Content-Transfer-Encoding: 7bit
775
+
776
+ Papaya
777
+  (0.1ms) SELECT COUNT(*) FROM "emails"
778
+ Mailhopper::Email Load (0.2ms) SELECT "emails".* FROM "emails" ORDER BY created_at DESC LIMIT 1
779
+  (0.5ms) rollback transaction
780
+  (0.0ms) begin transaction
781
+  (0.1ms) SELECT COUNT(*) FROM "emails"
782
+ Rendered sample_mailer/hello.text.erb (0.1ms)
783
+  (0.1ms) SAVEPOINT active_record_1
784
+ SQL (0.4ms) INSERT INTO "emails" ("bcc_address", "cc_address", "content", "created_at", "from_address", "reply_to_address", "sent_at", "subject", "to_address", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["bcc_address", nil], ["cc_address", nil], ["content", "Date: Mon, 07 May 2012 22:22:42 -0400\r\nFrom: from@example.com\r\nTo: to@example.com\r\nMessage-ID: <4fa883721afc3_120dc3fdc91834cdc4041a@dgmpro.local.mail>\r\nSubject: Hiya!\r\nMime-Version: 1.0\r\nContent-Type: text/plain;\r\n charset=UTF-8\r\nContent-Transfer-Encoding: 7bit\r\n\r\nPapaya"], ["created_at", Tue, 08 May 2012 02:22:42 UTC +00:00], ["from_address", "from@example.com"], ["reply_to_address", nil], ["sent_at", nil], ["subject", "Hiya!"], ["to_address", "to@example.com"], ["updated_at", Tue, 08 May 2012 02:22:42 UTC +00:00]]
785
+  (0.0ms) RELEASE SAVEPOINT active_record_1
786
+
787
+ Sent mail to to@example.com (7ms)
788
+ Date: Mon, 07 May 2012 22:22:42 -0400
789
+ From: from@example.com
790
+ To: to@example.com
791
+ Message-ID: <4fa883721afc3_120dc3fdc91834cdc4041a@dgmpro.local.mail>
792
+ Subject: Hiya!
793
+ Mime-Version: 1.0
794
+ Content-Type: text/plain;
795
+ charset=UTF-8
796
+ Content-Transfer-Encoding: 7bit
797
+
798
+ Papaya
799
+  (0.1ms) SELECT COUNT(*) FROM "emails"
800
+ Mailhopper::Email Load (0.2ms) SELECT "emails".* FROM "emails" ORDER BY created_at DESC LIMIT 1
801
+  (0.4ms) rollback transaction
802
+  (0.0ms) begin transaction
803
+  (0.1ms) SELECT COUNT(*) FROM "emails"
804
+ Rendered sample_mailer/hello.text.erb (0.1ms)
805
+  (0.0ms) SAVEPOINT active_record_1
806
+ SQL (0.3ms) INSERT INTO "emails" ("bcc_address", "cc_address", "content", "created_at", "from_address", "reply_to_address", "sent_at", "subject", "to_address", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["bcc_address", nil], ["cc_address", nil], ["content", "Date: Mon, 07 May 2012 22:22:42 -0400\r\nfrom: from.@example.com\r\nto: to.@example.com\r\nMessage-ID: <4fa883721eae8_120dc3fdc91834cdc405bc@dgmpro.local.mail>\r\nSubject: Hiya!\r\nMime-Version: 1.0\r\nContent-Type: text/plain;\r\n charset=UTF-8\r\nContent-Transfer-Encoding: 7bit\r\n\r\nPapaya"], ["created_at", Tue, 08 May 2012 02:22:42 UTC +00:00], ["from_address", "from.@example.com"], ["reply_to_address", nil], ["sent_at", nil], ["subject", "Hiya!"], ["to_address", "to.@example.com"], ["updated_at", Tue, 08 May 2012 02:22:42 UTC +00:00]]
807
+  (0.0ms) RELEASE SAVEPOINT active_record_1
808
+
809
+ Sent mail to to.@example.com (6ms)
810
+ Date: Mon, 07 May 2012 22:22:42 -0400
811
+ from: from.@example.com
812
+ to: to.@example.com
813
+ Message-ID: <4fa883721eae8_120dc3fdc91834cdc405bc@dgmpro.local.mail>
814
+ Subject: Hiya!
815
+ Mime-Version: 1.0
816
+ Content-Type: text/plain;
817
+ charset=UTF-8
818
+ Content-Transfer-Encoding: 7bit
819
+
820
+ Papaya
821
+  (0.1ms) SELECT COUNT(*) FROM "emails"
822
+ Mailhopper::Email Load (0.1ms) SELECT "emails".* FROM "emails" ORDER BY created_at DESC LIMIT 1
823
+  (13.6ms) rollback transaction
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailhopper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-07 00:00:00.000000000 Z
12
+ date: 2012-05-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70149330109600 !ruby/object:Gem::Requirement
16
+ requirement: &70327828773120 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.1.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70149330109600
24
+ version_requirements: *70327828773120
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: sqlite3
27
- requirement: &70149330109100 !ruby/object:Gem::Requirement
27
+ requirement: &70327828772620 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.3.4
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70149330109100
35
+ version_requirements: *70327828772620
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec-rails
38
- requirement: &70149330108720 !ruby/object:Gem::Requirement
38
+ requirement: &70327828772240 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70149330108720
46
+ version_requirements: *70327828772240
47
47
  description: Mailhopper stores your application's emails in an ActiveRecord queue
48
48
  for asynchronous delivery. Use Mailhopper in combination with a delivery agent such
49
49
  as DelayedMailhopper.