actionmailbox 0.1.0 → 6.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/{LICENSE → MIT-LICENSE} +1 -1
  4. data/README.md +2 -267
  5. data/app/controllers/action_mailbox/base_controller.rb +26 -31
  6. data/app/controllers/action_mailbox/ingresses/amazon/inbound_emails_controller.rb +48 -44
  7. data/app/controllers/action_mailbox/ingresses/mailgun/inbound_emails_controller.rb +88 -84
  8. data/app/controllers/action_mailbox/ingresses/mandrill/inbound_emails_controller.rb +64 -60
  9. data/app/controllers/action_mailbox/ingresses/postmark/inbound_emails_controller.rb +62 -0
  10. data/app/controllers/action_mailbox/ingresses/relay/inbound_emails_controller.rb +65 -0
  11. data/app/controllers/action_mailbox/ingresses/sendgrid/inbound_emails_controller.rb +51 -47
  12. data/app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb +27 -20
  13. data/app/controllers/rails/conductor/action_mailbox/reroutes_controller.rb +15 -11
  14. data/app/controllers/rails/conductor/base_controller.rb +12 -8
  15. data/app/jobs/action_mailbox/incineration_job.rb +17 -13
  16. data/app/jobs/action_mailbox/routing_job.rb +10 -6
  17. data/app/models/action_mailbox/inbound_email.rb +43 -37
  18. data/app/models/action_mailbox/inbound_email/incineratable.rb +5 -3
  19. data/app/models/action_mailbox/inbound_email/incineratable/incineration.rb +21 -17
  20. data/app/models/action_mailbox/inbound_email/message_id.rb +22 -20
  21. data/app/models/action_mailbox/inbound_email/routable.rb +7 -5
  22. data/app/views/rails/conductor/action_mailbox/inbound_emails/new.html.erb +5 -0
  23. data/config/routes.rb +2 -1
  24. data/db/migrate/20180917164000_create_action_mailbox_tables.rb +10 -4
  25. data/lib/action_mailbox.rb +2 -1
  26. data/lib/action_mailbox/base.rb +100 -93
  27. data/lib/action_mailbox/callbacks.rb +3 -1
  28. data/lib/action_mailbox/engine.rb +9 -1
  29. data/lib/action_mailbox/gem_version.rb +17 -0
  30. data/lib/action_mailbox/mail_ext.rb +2 -0
  31. data/lib/action_mailbox/mail_ext/address_equality.rb +7 -3
  32. data/lib/action_mailbox/mail_ext/address_wrapping.rb +7 -3
  33. data/lib/action_mailbox/mail_ext/addresses.rb +22 -18
  34. data/lib/action_mailbox/mail_ext/from_source.rb +2 -0
  35. data/lib/action_mailbox/mail_ext/recipients.rb +7 -3
  36. data/lib/action_mailbox/{postfix_relayer.rb → relayer.rb} +18 -10
  37. data/lib/action_mailbox/router.rb +30 -26
  38. data/lib/action_mailbox/router/route.rb +34 -30
  39. data/lib/action_mailbox/routing.rb +3 -1
  40. data/lib/action_mailbox/test_case.rb +4 -0
  41. data/lib/action_mailbox/test_helper.rb +8 -6
  42. data/lib/action_mailbox/version.rb +8 -1
  43. data/lib/rails/generators/installer.rb +10 -0
  44. data/lib/rails/generators/mailbox/USAGE +12 -0
  45. data/lib/rails/generators/mailbox/mailbox_generator.rb +32 -0
  46. data/lib/{templates/mailboxes/application_mailbox.rb → rails/generators/mailbox/templates/application_mailbox.rb.tt} +1 -1
  47. data/lib/rails/generators/mailbox/templates/mailbox.rb.tt +4 -0
  48. data/lib/rails/generators/test_unit/mailbox_generator.rb +20 -0
  49. data/lib/rails/generators/test_unit/templates/mailbox_test.rb.tt +13 -0
  50. data/lib/tasks/ingress.rake +53 -5
  51. data/lib/tasks/install.rake +1 -1
  52. metadata +66 -237
  53. data/.gitignore +0 -2
  54. data/Gemfile +0 -8
  55. data/Gemfile.lock +0 -159
  56. data/Rakefile +0 -27
  57. data/actionmailbox.gemspec +0 -27
  58. data/app/controllers/action_mailbox/ingresses/postfix/inbound_emails_controller.rb +0 -55
  59. data/bin/test +0 -5
  60. data/lib/templates/installer.rb +0 -4
  61. data/test/controllers/ingresses/amazon/inbound_emails_controller_test.rb +0 -20
  62. data/test/controllers/ingresses/mailgun/inbound_emails_controller_test.rb +0 -89
  63. data/test/controllers/ingresses/mandrill/inbound_emails_controller_test.rb +0 -58
  64. data/test/controllers/ingresses/postfix/inbound_emails_controller_test.rb +0 -54
  65. data/test/controllers/ingresses/sendgrid/inbound_emails_controller_test.rb +0 -44
  66. data/test/dummy/.babelrc +0 -18
  67. data/test/dummy/.gitignore +0 -3
  68. data/test/dummy/.postcssrc.yml +0 -3
  69. data/test/dummy/Rakefile +0 -6
  70. data/test/dummy/app/assets/config/manifest.js +0 -3
  71. data/test/dummy/app/assets/images/.keep +0 -0
  72. data/test/dummy/app/assets/stylesheets/application.css +0 -15
  73. data/test/dummy/app/assets/stylesheets/scaffold.css +0 -80
  74. data/test/dummy/app/channels/application_cable/channel.rb +0 -4
  75. data/test/dummy/app/channels/application_cable/connection.rb +0 -4
  76. data/test/dummy/app/controllers/application_controller.rb +0 -2
  77. data/test/dummy/app/controllers/concerns/.keep +0 -0
  78. data/test/dummy/app/helpers/application_helper.rb +0 -2
  79. data/test/dummy/app/javascript/packs/application.js +0 -0
  80. data/test/dummy/app/jobs/application_job.rb +0 -2
  81. data/test/dummy/app/mailboxes/application_mailbox.rb +0 -2
  82. data/test/dummy/app/mailboxes/messages_mailbox.rb +0 -4
  83. data/test/dummy/app/mailers/application_mailer.rb +0 -4
  84. data/test/dummy/app/models/application_record.rb +0 -3
  85. data/test/dummy/app/models/concerns/.keep +0 -0
  86. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  87. data/test/dummy/app/views/layouts/mailer.html.erb +0 -13
  88. data/test/dummy/app/views/layouts/mailer.text.erb +0 -1
  89. data/test/dummy/bin/bundle +0 -3
  90. data/test/dummy/bin/rails +0 -4
  91. data/test/dummy/bin/rake +0 -4
  92. data/test/dummy/bin/setup +0 -36
  93. data/test/dummy/bin/update +0 -31
  94. data/test/dummy/bin/yarn +0 -11
  95. data/test/dummy/config.ru +0 -5
  96. data/test/dummy/config/application.rb +0 -19
  97. data/test/dummy/config/boot.rb +0 -5
  98. data/test/dummy/config/cable.yml +0 -10
  99. data/test/dummy/config/database.yml +0 -25
  100. data/test/dummy/config/environment.rb +0 -5
  101. data/test/dummy/config/environments/development.rb +0 -63
  102. data/test/dummy/config/environments/production.rb +0 -96
  103. data/test/dummy/config/environments/test.rb +0 -46
  104. data/test/dummy/config/initializers/application_controller_renderer.rb +0 -8
  105. data/test/dummy/config/initializers/assets.rb +0 -14
  106. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  107. data/test/dummy/config/initializers/content_security_policy.rb +0 -22
  108. data/test/dummy/config/initializers/cookies_serializer.rb +0 -5
  109. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  110. data/test/dummy/config/initializers/inflections.rb +0 -16
  111. data/test/dummy/config/initializers/mime_types.rb +0 -4
  112. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  113. data/test/dummy/config/locales/en.yml +0 -33
  114. data/test/dummy/config/puma.rb +0 -34
  115. data/test/dummy/config/routes.rb +0 -4
  116. data/test/dummy/config/spring.rb +0 -6
  117. data/test/dummy/config/storage.yml +0 -35
  118. data/test/dummy/config/webpack/development.js +0 -3
  119. data/test/dummy/config/webpack/environment.js +0 -3
  120. data/test/dummy/config/webpack/production.js +0 -3
  121. data/test/dummy/config/webpack/test.js +0 -3
  122. data/test/dummy/config/webpacker.yml +0 -65
  123. data/test/dummy/db/migrate/20180208205311_create_action_mailroom_tables.rb +0 -11
  124. data/test/dummy/db/migrate/20180212164506_create_active_storage_tables.active_storage.rb +0 -26
  125. data/test/dummy/db/schema.rb +0 -43
  126. data/test/dummy/lib/assets/.keep +0 -0
  127. data/test/dummy/log/.keep +0 -0
  128. data/test/dummy/package.json +0 -11
  129. data/test/dummy/public/404.html +0 -67
  130. data/test/dummy/public/422.html +0 -67
  131. data/test/dummy/public/500.html +0 -66
  132. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  133. data/test/dummy/public/apple-touch-icon.png +0 -0
  134. data/test/dummy/public/favicon.ico +0 -0
  135. data/test/dummy/storage/.keep +0 -0
  136. data/test/dummy/yarn.lock +0 -6071
  137. data/test/fixtures/files/welcome.eml +0 -631
  138. data/test/jobs/incineration_job_test.rb +0 -17
  139. data/test/test_helper.rb +0 -54
  140. data/test/unit/inbound_email/incineration_test.rb +0 -45
  141. data/test/unit/inbound_email/message_id_test.rb +0 -13
  142. data/test/unit/inbound_email_test.rb +0 -13
  143. data/test/unit/mail_ext/address_equality_test.rb +0 -9
  144. data/test/unit/mail_ext/address_wrapping_test.rb +0 -11
  145. data/test/unit/mail_ext/recipients_test.rb +0 -33
  146. data/test/unit/mailbox/bouncing_test.rb +0 -29
  147. data/test/unit/mailbox/callbacks_test.rb +0 -75
  148. data/test/unit/mailbox/routing_test.rb +0 -30
  149. data/test/unit/mailbox/state_test.rb +0 -49
  150. data/test/unit/postfix_relayer_test.rb +0 -90
  151. data/test/unit/router_test.rb +0 -137
@@ -1,38 +1,42 @@
1
- # Encapsulates the routes that live on the ApplicationMailbox and performs the actual routing when
2
- # an inbound_email is received.
3
- class ActionMailbox::Router
4
- class RoutingError < StandardError; end
1
+ # frozen_string_literal: true
5
2
 
6
- def initialize
7
- @routes = []
8
- end
3
+ module ActionMailbox
4
+ # Encapsulates the routes that live on the ApplicationMailbox and performs the actual routing when
5
+ # an inbound_email is received.
6
+ class Router
7
+ class RoutingError < StandardError; end
9
8
 
10
- def add_routes(routes)
11
- routes.each do |(address, mailbox_name)|
12
- add_route address, to: mailbox_name
9
+ def initialize
10
+ @routes = []
13
11
  end
14
- end
15
12
 
16
- def add_route(address, to:)
17
- routes.append Route.new(address, to: to)
18
- end
19
-
20
- def route(inbound_email)
21
- if mailbox = match_to_mailbox(inbound_email)
22
- mailbox.receive(inbound_email)
23
- else
24
- inbound_email.bounced!
13
+ def add_routes(routes)
14
+ routes.each do |(address, mailbox_name)|
15
+ add_route address, to: mailbox_name
16
+ end
17
+ end
25
18
 
26
- raise RoutingError
19
+ def add_route(address, to:)
20
+ routes.append Route.new(address, to: to)
27
21
  end
28
- end
29
22
 
30
- private
31
- attr_reader :routes
23
+ def route(inbound_email)
24
+ if mailbox = match_to_mailbox(inbound_email)
25
+ mailbox.receive(inbound_email)
26
+ else
27
+ inbound_email.bounced!
32
28
 
33
- def match_to_mailbox(inbound_email)
34
- routes.detect { |route| route.match?(inbound_email) }.try(:mailbox_class)
29
+ raise RoutingError
30
+ end
35
31
  end
32
+
33
+ private
34
+ attr_reader :routes
35
+
36
+ def match_to_mailbox(inbound_email)
37
+ routes.detect { |route| route.match?(inbound_email) }.try(:mailbox_class)
38
+ end
39
+ end
36
40
  end
37
41
 
38
42
  require "action_mailbox/router/route"
@@ -1,38 +1,42 @@
1
- # Encapsulates a route, which can then be matched against an inbound_email and provide a lookup of the matching
2
- # mailbox class. See examples for the different route addresses and how to use them in the `ActionMailbox::Base`
3
- # documentation.
4
- class ActionMailbox::Router::Route
5
- attr_reader :address, :mailbox_name
1
+ # frozen_string_literal: true
6
2
 
7
- def initialize(address, to:)
8
- @address, @mailbox_name = address, to
3
+ module ActionMailbox
4
+ # Encapsulates a route, which can then be matched against an inbound_email and provide a lookup of the matching
5
+ # mailbox class. See examples for the different route addresses and how to use them in the +ActionMailbox::Base+
6
+ # documentation.
7
+ class Router::Route
8
+ attr_reader :address, :mailbox_name
9
9
 
10
- ensure_valid_address
11
- end
10
+ def initialize(address, to:)
11
+ @address, @mailbox_name = address, to
12
12
 
13
- def match?(inbound_email)
14
- case address
15
- when :all
16
- true
17
- when String
18
- inbound_email.mail.recipients.any? { |recipient| address.casecmp?(recipient) }
19
- when Regexp
20
- inbound_email.mail.recipients.any? { |recipient| address.match?(recipient) }
21
- when Proc
22
- address.call(inbound_email)
23
- else
24
- address.match?(inbound_email)
13
+ ensure_valid_address
25
14
  end
26
- end
27
15
 
28
- def mailbox_class
29
- "#{mailbox_name.to_s.camelize}Mailbox".constantize
30
- end
31
-
32
- private
33
- def ensure_valid_address
34
- unless [ Symbol, String, Regexp, Proc ].any? { |klass| address.is_a?(klass) } || address.respond_to?(:match?)
35
- raise ArgumentError, "Expected a Symbol, String, Regexp, Proc, or matchable, got #{address.inspect}"
16
+ def match?(inbound_email)
17
+ case address
18
+ when :all
19
+ true
20
+ when String
21
+ inbound_email.mail.recipients.any? { |recipient| address.casecmp?(recipient) }
22
+ when Regexp
23
+ inbound_email.mail.recipients.any? { |recipient| address.match?(recipient) }
24
+ when Proc
25
+ address.call(inbound_email)
26
+ else
27
+ address.match?(inbound_email)
36
28
  end
37
29
  end
30
+
31
+ def mailbox_class
32
+ "#{mailbox_name.to_s.camelize}Mailbox".constantize
33
+ end
34
+
35
+ private
36
+ def ensure_valid_address
37
+ unless [ Symbol, String, Regexp, Proc ].any? { |klass| address.is_a?(klass) } || address.respond_to?(:match?)
38
+ raise ArgumentError, "Expected a Symbol, String, Regexp, Proc, or matchable, got #{address.inspect}"
39
+ end
40
+ end
41
+ end
38
42
  end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionMailbox
2
- # See `ActionMailbox::Base` for how to specify routing.
4
+ # See +ActionMailbox::Base+ for how to specify routing.
3
5
  module Routing
4
6
  extend ActiveSupport::Concern
5
7
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "action_mailbox/test_helper"
2
4
  require "active_support/test_case"
3
5
 
@@ -6,3 +8,5 @@ module ActionMailbox
6
8
  include ActionMailbox::TestHelper
7
9
  end
8
10
  end
11
+
12
+ ActiveSupport.run_load_hooks :action_mailbox_test_case, ActionMailbox::TestCase
@@ -1,39 +1,41 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "mail"
2
4
 
3
5
  module ActionMailbox
4
6
  module TestHelper
5
- # Create an `InboundEmail` record using an eml fixture in the format of message/rfc822
7
+ # Create an +InboundEmail+ record using an eml fixture in the format of message/rfc822
6
8
  # referenced with +fixture_name+ located in +test/fixtures/files/fixture_name+.
7
9
  def create_inbound_email_from_fixture(fixture_name, status: :processing)
8
10
  create_inbound_email_from_source file_fixture(fixture_name).read, status: status
9
11
  end
10
12
 
11
- # Create an `InboundEmail` by specifying it using `Mail.new` options. Example:
13
+ # Create an +InboundEmail+ by specifying it using +Mail.new+ options. Example:
12
14
  #
13
15
  # create_inbound_email_from_mail(from: "david@loudthinking.com", subject: "Hello!")
14
16
  def create_inbound_email_from_mail(status: :processing, **mail_options)
15
17
  create_inbound_email_from_source Mail.new(mail_options).to_s, status: status
16
18
  end
17
19
 
18
- # Create an `InboundEmail` using the raw rfc822 `source` as text.
20
+ # Create an +InboundEmail+ using the raw rfc822 +source+ as text.
19
21
  def create_inbound_email_from_source(source, status: :processing)
20
22
  ActionMailbox::InboundEmail.create_and_extract_message_id! source, status: status
21
23
  end
22
24
 
23
25
 
24
- # Create an `InboundEmail` from fixture using the same arguments as `create_inbound_email_from_fixture`
26
+ # Create an +InboundEmail+ from fixture using the same arguments as +create_inbound_email_from_fixture+
25
27
  # and immediately route it to processing.
26
28
  def receive_inbound_email_from_fixture(*args)
27
29
  create_inbound_email_from_fixture(*args).tap(&:route)
28
30
  end
29
31
 
30
- # Create an `InboundEmail` from fixture using the same arguments as `create_inbound_email_from_mail`
32
+ # Create an +InboundEmail+ from fixture using the same arguments as +create_inbound_email_from_mail+
31
33
  # and immediately route it to processing.
32
34
  def receive_inbound_email_from_mail(**kwargs)
33
35
  create_inbound_email_from_mail(**kwargs).tap(&:route)
34
36
  end
35
37
 
36
- # Create an `InboundEmail` from fixture using the same arguments as `create_inbound_email_from_source`
38
+ # Create an +InboundEmail+ from fixture using the same arguments as +create_inbound_email_from_source+
37
39
  # and immediately route it to processing.
38
40
  def receive_inbound_email_from_source(**kwargs)
39
41
  create_inbound_email_from_source(**kwargs).tap(&:route)
@@ -1,3 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "gem_version"
4
+
1
5
  module ActionMailbox
2
- VERSION = '0.1.0'
6
+ # Returns the currently-loaded version of Action Mailbox as a <tt>Gem::Version</tt>.
7
+ def self.version
8
+ gem_version
9
+ end
3
10
  end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ say "Copying application_mailbox.rb to app/mailboxes"
4
+ copy_file "#{__dir__}/mailbox/templates/application_mailbox.rb", "app/mailboxes/application_mailbox.rb"
5
+
6
+ environment <<~end_of_config, env: "production"
7
+ # Prepare the ingress controller used to receive mail
8
+ # config.action_mailbox.ingress = :amazon
9
+
10
+ end_of_config
@@ -0,0 +1,12 @@
1
+ Description:
2
+ ============
3
+ Stubs out a new mailbox class in app/mailboxes and invokes your template
4
+ engine and test framework generators.
5
+
6
+ Example:
7
+ ========
8
+ rails generate mailbox inbox
9
+
10
+ creates a InboxMailbox class and test:
11
+ Mailbox: app/mailboxes/inbox_mailbox.rb
12
+ Test: test/mailboxes/inbox_mailbox_test.rb
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rails
4
+ module Generators
5
+ class MailboxGenerator < NamedBase
6
+ source_root File.expand_path("templates", __dir__)
7
+
8
+ check_class_collision suffix: "Mailbox"
9
+
10
+ def create_mailbox_file
11
+ template "mailbox.rb", File.join("app/mailboxes", class_path, "#{file_name}_mailbox.rb")
12
+
13
+ in_root do
14
+ if behavior == :invoke && !File.exist?(application_mailbox_file_name)
15
+ template "application_mailbox.rb", application_mailbox_file_name
16
+ end
17
+ end
18
+ end
19
+
20
+ hook_for :test_framework
21
+
22
+ private
23
+ def file_name # :doc:
24
+ @_file_name ||= super.sub(/_mailbox\z/i, "")
25
+ end
26
+
27
+ def application_mailbox_file_name
28
+ "app/mailboxes/application_mailbox.rb"
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,3 +1,3 @@
1
1
  class ApplicationMailbox < ActionMailbox::Base
2
- # route /something/i => :somewhere
2
+ # routing /something/i => :somewhere
3
3
  end
@@ -0,0 +1,4 @@
1
+ class <%= class_name %>Mailbox < ApplicationMailbox
2
+ def process
3
+ end
4
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TestUnit
4
+ module Generators
5
+ class MailboxGenerator < ::Rails::Generators::NamedBase
6
+ source_root File.expand_path("templates", __dir__)
7
+
8
+ check_class_collision suffix: "MailboxTest"
9
+
10
+ def create_test_files
11
+ template "mailbox_test.rb", File.join("test/mailboxes", class_path, "#{file_name}_mailbox_test.rb")
12
+ end
13
+
14
+ private
15
+ def file_name # :doc:
16
+ @_file_name ||= super.sub(/_mailbox\z/i, "")
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class <%= class_name %>MailboxTest < ActionMailbox::TestCase
6
+ # test "receive mail" do
7
+ # receive_inbound_email_from_mail \
8
+ # to: '"someone" <someone@example.com>',
9
+ # from: '"else" <else@example.com>',
10
+ # subject: "Hello world!",
11
+ # body: "Hello?"
12
+ # end
13
+ end
@@ -2,12 +2,37 @@
2
2
 
3
3
  namespace :action_mailbox do
4
4
  namespace :ingress do
5
- desc "Pipe an inbound email from STDIN to the Postfix ingress (URL and INGRESS_PASSWORD required)"
6
- task :postfix do
5
+ task :environment do
7
6
  require "active_support"
8
7
  require "active_support/core_ext/object/blank"
9
- require "action_mailbox/postfix_relayer"
8
+ require "action_mailbox/relayer"
9
+ end
10
+
11
+ desc "Relay an inbound email from Exim to Action Mailbox (URL and INGRESS_PASSWORD required)"
12
+ task exim: "action_mailbox:ingress:environment" do
13
+ url, password = ENV.values_at("URL", "INGRESS_PASSWORD")
14
+
15
+ if url.blank? || password.blank?
16
+ print "URL and INGRESS_PASSWORD are required"
17
+ exit 64 # EX_USAGE
18
+ end
19
+
20
+ ActionMailbox::Relayer.new(url: url, password: password).relay(STDIN.read).tap do |result|
21
+ print result.message
22
+
23
+ case
24
+ when result.success?
25
+ exit 0
26
+ when result.transient_failure?
27
+ exit 75 # EX_TEMPFAIL
28
+ else
29
+ exit 69 # EX_UNAVAILABLE
30
+ end
31
+ end
32
+ end
10
33
 
34
+ desc "Relay an inbound email from Postfix to Action Mailbox (URL and INGRESS_PASSWORD required)"
35
+ task postfix: "action_mailbox:ingress:environment" do
11
36
  url, password = ENV.values_at("URL", "INGRESS_PASSWORD")
12
37
 
13
38
  if url.blank? || password.blank?
@@ -15,10 +40,33 @@ namespace :action_mailbox do
15
40
  exit 1
16
41
  end
17
42
 
18
- ActionMailbox::PostfixRelayer.new(url: url, password: password).relay(STDIN.read).tap do |result|
19
- print result.output
43
+ ActionMailbox::Relayer.new(url: url, password: password).relay(STDIN.read).tap do |result|
44
+ print "#{result.status_code} #{result.message}"
20
45
  exit result.success?
21
46
  end
22
47
  end
48
+
49
+ desc "Relay an inbound email from Qmail to Action Mailbox (URL and INGRESS_PASSWORD required)"
50
+ task qmail: "action_mailbox:ingress:environment" do
51
+ url, password = ENV.values_at("URL", "INGRESS_PASSWORD")
52
+
53
+ if url.blank? || password.blank?
54
+ print "URL and INGRESS_PASSWORD are required"
55
+ exit 111
56
+ end
57
+
58
+ ActionMailbox::Relayer.new(url: url, password: password).relay(STDIN.read).tap do |result|
59
+ print result.message
60
+
61
+ case
62
+ when result.success?
63
+ exit 0
64
+ when result.transient_failure?
65
+ exit 111
66
+ else
67
+ exit 100
68
+ end
69
+ end
70
+ end
23
71
  end
24
72
  end
@@ -8,7 +8,7 @@ namespace :action_mailbox do
8
8
  task install: %w[ environment run_installer copy_migrations ]
9
9
 
10
10
  task :run_installer do
11
- installer_template = File.expand_path("../templates/installer.rb", __dir__)
11
+ installer_template = File.expand_path("../rails/generators/installer.rb", __dir__)
12
12
  system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{installer_template}"
13
13
  end
14
14
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionmailbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 6.0.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
@@ -9,79 +9,93 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-12-14 00:00:00.000000000 Z
12
+ date: 2019-01-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: rails
15
+ name: activesupport
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ">="
18
+ - - '='
19
19
  - !ruby/object:Gem::Version
20
- version: 5.2.0
20
+ version: 6.0.0.beta1
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ">="
25
+ - - '='
26
26
  - !ruby/object:Gem::Version
27
- version: 5.2.0
27
+ version: 6.0.0.beta1
28
28
  - !ruby/object:Gem::Dependency
29
- name: bundler
29
+ name: activerecord
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - "~>"
32
+ - - '='
33
33
  - !ruby/object:Gem::Version
34
- version: '1.15'
35
- type: :development
34
+ version: 6.0.0.beta1
35
+ type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - "~>"
39
+ - - '='
40
40
  - !ruby/object:Gem::Version
41
- version: '1.15'
41
+ version: 6.0.0.beta1
42
42
  - !ruby/object:Gem::Dependency
43
- name: sqlite3
43
+ name: activestorage
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ">="
46
+ - - '='
47
47
  - !ruby/object:Gem::Version
48
- version: '0'
49
- type: :development
48
+ version: 6.0.0.beta1
49
+ type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ">="
53
+ - - '='
54
54
  - !ruby/object:Gem::Version
55
- version: '0'
55
+ version: 6.0.0.beta1
56
56
  - !ruby/object:Gem::Dependency
57
- name: byebug
57
+ name: activejob
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ">="
60
+ - - '='
61
61
  - !ruby/object:Gem::Version
62
- version: '0'
63
- type: :development
62
+ version: 6.0.0.beta1
63
+ type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ">="
67
+ - - '='
68
+ - !ruby/object:Gem::Version
69
+ version: 6.0.0.beta1
70
+ - !ruby/object:Gem::Dependency
71
+ name: actionpack
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '='
75
+ - !ruby/object:Gem::Version
76
+ version: 6.0.0.beta1
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '='
68
82
  - !ruby/object:Gem::Version
69
- version: '0'
83
+ version: 6.0.0.beta1
70
84
  - !ruby/object:Gem::Dependency
71
- name: webmock
85
+ name: mail
72
86
  requirement: !ruby/object:Gem::Requirement
73
87
  requirements:
74
88
  - - ">="
75
89
  - !ruby/object:Gem::Version
76
- version: '0'
77
- type: :development
90
+ version: 2.7.1
91
+ type: :runtime
78
92
  prerelease: false
79
93
  version_requirements: !ruby/object:Gem::Requirement
80
94
  requirements:
81
95
  - - ">="
82
96
  - !ruby/object:Gem::Version
83
- version: '0'
84
- description:
97
+ version: 2.7.1
98
+ description: Receive and process incoming emails in Rails applications.
85
99
  email:
86
100
  - david@loudthinking.com
87
101
  - george@basecamp.com
@@ -89,18 +103,15 @@ executables: []
89
103
  extensions: []
90
104
  extra_rdoc_files: []
91
105
  files:
92
- - ".gitignore"
93
- - Gemfile
94
- - Gemfile.lock
95
- - LICENSE
106
+ - CHANGELOG.md
107
+ - MIT-LICENSE
96
108
  - README.md
97
- - Rakefile
98
- - actionmailbox.gemspec
99
109
  - app/controllers/action_mailbox/base_controller.rb
100
110
  - app/controllers/action_mailbox/ingresses/amazon/inbound_emails_controller.rb
101
111
  - app/controllers/action_mailbox/ingresses/mailgun/inbound_emails_controller.rb
102
112
  - app/controllers/action_mailbox/ingresses/mandrill/inbound_emails_controller.rb
103
- - app/controllers/action_mailbox/ingresses/postfix/inbound_emails_controller.rb
113
+ - app/controllers/action_mailbox/ingresses/postmark/inbound_emails_controller.rb
114
+ - app/controllers/action_mailbox/ingresses/relay/inbound_emails_controller.rb
104
115
  - app/controllers/action_mailbox/ingresses/sendgrid/inbound_emails_controller.rb
105
116
  - app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
106
117
  - app/controllers/rails/conductor/action_mailbox/reroutes_controller.rb
@@ -116,128 +127,41 @@ files:
116
127
  - app/views/rails/conductor/action_mailbox/inbound_emails/index.html.erb
117
128
  - app/views/rails/conductor/action_mailbox/inbound_emails/new.html.erb
118
129
  - app/views/rails/conductor/action_mailbox/inbound_emails/show.html.erb
119
- - bin/test
120
130
  - config/routes.rb
121
131
  - db/migrate/20180917164000_create_action_mailbox_tables.rb
122
132
  - lib/action_mailbox.rb
123
133
  - lib/action_mailbox/base.rb
124
134
  - lib/action_mailbox/callbacks.rb
125
135
  - lib/action_mailbox/engine.rb
136
+ - lib/action_mailbox/gem_version.rb
126
137
  - lib/action_mailbox/mail_ext.rb
127
138
  - lib/action_mailbox/mail_ext/address_equality.rb
128
139
  - lib/action_mailbox/mail_ext/address_wrapping.rb
129
140
  - lib/action_mailbox/mail_ext/addresses.rb
130
141
  - lib/action_mailbox/mail_ext/from_source.rb
131
142
  - lib/action_mailbox/mail_ext/recipients.rb
132
- - lib/action_mailbox/postfix_relayer.rb
143
+ - lib/action_mailbox/relayer.rb
133
144
  - lib/action_mailbox/router.rb
134
145
  - lib/action_mailbox/router/route.rb
135
146
  - lib/action_mailbox/routing.rb
136
147
  - lib/action_mailbox/test_case.rb
137
148
  - lib/action_mailbox/test_helper.rb
138
149
  - lib/action_mailbox/version.rb
150
+ - lib/rails/generators/installer.rb
151
+ - lib/rails/generators/mailbox/USAGE
152
+ - lib/rails/generators/mailbox/mailbox_generator.rb
153
+ - lib/rails/generators/mailbox/templates/application_mailbox.rb.tt
154
+ - lib/rails/generators/mailbox/templates/mailbox.rb.tt
155
+ - lib/rails/generators/test_unit/mailbox_generator.rb
156
+ - lib/rails/generators/test_unit/templates/mailbox_test.rb.tt
139
157
  - lib/tasks/ingress.rake
140
158
  - lib/tasks/install.rake
141
- - lib/templates/installer.rb
142
- - lib/templates/mailboxes/application_mailbox.rb
143
- - test/controllers/ingresses/amazon/inbound_emails_controller_test.rb
144
- - test/controllers/ingresses/mailgun/inbound_emails_controller_test.rb
145
- - test/controllers/ingresses/mandrill/inbound_emails_controller_test.rb
146
- - test/controllers/ingresses/postfix/inbound_emails_controller_test.rb
147
- - test/controllers/ingresses/sendgrid/inbound_emails_controller_test.rb
148
- - test/dummy/.babelrc
149
- - test/dummy/.gitignore
150
- - test/dummy/.postcssrc.yml
151
- - test/dummy/Rakefile
152
- - test/dummy/app/assets/config/manifest.js
153
- - test/dummy/app/assets/images/.keep
154
- - test/dummy/app/assets/stylesheets/application.css
155
- - test/dummy/app/assets/stylesheets/scaffold.css
156
- - test/dummy/app/channels/application_cable/channel.rb
157
- - test/dummy/app/channels/application_cable/connection.rb
158
- - test/dummy/app/controllers/application_controller.rb
159
- - test/dummy/app/controllers/concerns/.keep
160
- - test/dummy/app/helpers/application_helper.rb
161
- - test/dummy/app/javascript/packs/application.js
162
- - test/dummy/app/jobs/application_job.rb
163
- - test/dummy/app/mailboxes/application_mailbox.rb
164
- - test/dummy/app/mailboxes/messages_mailbox.rb
165
- - test/dummy/app/mailers/application_mailer.rb
166
- - test/dummy/app/models/application_record.rb
167
- - test/dummy/app/models/concerns/.keep
168
- - test/dummy/app/views/layouts/application.html.erb
169
- - test/dummy/app/views/layouts/mailer.html.erb
170
- - test/dummy/app/views/layouts/mailer.text.erb
171
- - test/dummy/bin/bundle
172
- - test/dummy/bin/rails
173
- - test/dummy/bin/rake
174
- - test/dummy/bin/setup
175
- - test/dummy/bin/update
176
- - test/dummy/bin/yarn
177
- - test/dummy/config.ru
178
- - test/dummy/config/application.rb
179
- - test/dummy/config/boot.rb
180
- - test/dummy/config/cable.yml
181
- - test/dummy/config/database.yml
182
- - test/dummy/config/environment.rb
183
- - test/dummy/config/environments/development.rb
184
- - test/dummy/config/environments/production.rb
185
- - test/dummy/config/environments/test.rb
186
- - test/dummy/config/initializers/application_controller_renderer.rb
187
- - test/dummy/config/initializers/assets.rb
188
- - test/dummy/config/initializers/backtrace_silencers.rb
189
- - test/dummy/config/initializers/content_security_policy.rb
190
- - test/dummy/config/initializers/cookies_serializer.rb
191
- - test/dummy/config/initializers/filter_parameter_logging.rb
192
- - test/dummy/config/initializers/inflections.rb
193
- - test/dummy/config/initializers/mime_types.rb
194
- - test/dummy/config/initializers/wrap_parameters.rb
195
- - test/dummy/config/locales/en.yml
196
- - test/dummy/config/puma.rb
197
- - test/dummy/config/routes.rb
198
- - test/dummy/config/spring.rb
199
- - test/dummy/config/storage.yml
200
- - test/dummy/config/webpack/development.js
201
- - test/dummy/config/webpack/environment.js
202
- - test/dummy/config/webpack/production.js
203
- - test/dummy/config/webpack/test.js
204
- - test/dummy/config/webpacker.yml
205
- - test/dummy/db/migrate/20180208205311_create_action_mailroom_tables.rb
206
- - test/dummy/db/migrate/20180212164506_create_active_storage_tables.active_storage.rb
207
- - test/dummy/db/schema.rb
208
- - test/dummy/lib/assets/.keep
209
- - test/dummy/log/.keep
210
- - test/dummy/log/development.log
211
- - test/dummy/package.json
212
- - test/dummy/public/404.html
213
- - test/dummy/public/422.html
214
- - test/dummy/public/500.html
215
- - test/dummy/public/apple-touch-icon-precomposed.png
216
- - test/dummy/public/apple-touch-icon.png
217
- - test/dummy/public/favicon.ico
218
- - test/dummy/storage/.keep
219
- - test/dummy/tmp/.keep
220
- - test/dummy/tmp/storage/.keep
221
- - test/dummy/yarn.lock
222
- - test/fixtures/files/welcome.eml
223
- - test/jobs/incineration_job_test.rb
224
- - test/test_helper.rb
225
- - test/unit/inbound_email/incineration_test.rb
226
- - test/unit/inbound_email/message_id_test.rb
227
- - test/unit/inbound_email_test.rb
228
- - test/unit/mail_ext/address_equality_test.rb
229
- - test/unit/mail_ext/address_wrapping_test.rb
230
- - test/unit/mail_ext/recipients_test.rb
231
- - test/unit/mailbox/bouncing_test.rb
232
- - test/unit/mailbox/callbacks_test.rb
233
- - test/unit/mailbox/routing_test.rb
234
- - test/unit/mailbox/state_test.rb
235
- - test/unit/postfix_relayer_test.rb
236
- - test/unit/router_test.rb
237
- homepage: https://github.com/rails/actionmailbox
159
+ homepage: https://rubyonrails.org
238
160
  licenses:
239
161
  - MIT
240
- metadata: {}
162
+ metadata:
163
+ source_code_uri: https://github.com/rails/rails/tree/v6.0.0.beta1/actionmailbox
164
+ changelog_uri: https://github.com/rails/rails/blob/v6.0.0.beta1/actionmailbox/CHANGELOG.md
241
165
  post_install_message:
242
166
  rdoc_options: []
243
167
  require_paths:
@@ -249,107 +173,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
249
173
  version: 2.5.0
250
174
  required_rubygems_version: !ruby/object:Gem::Requirement
251
175
  requirements:
252
- - - ">="
176
+ - - ">"
253
177
  - !ruby/object:Gem::Version
254
- version: '0'
178
+ version: 1.3.1
255
179
  requirements: []
256
- rubyforge_project:
257
- rubygems_version: 2.7.3
180
+ rubygems_version: 3.0.1
258
181
  signing_key:
259
182
  specification_version: 4
260
- summary: Receive and process incoming emails in Rails
261
- test_files:
262
- - test/controllers/ingresses/amazon/inbound_emails_controller_test.rb
263
- - test/controllers/ingresses/mailgun/inbound_emails_controller_test.rb
264
- - test/controllers/ingresses/mandrill/inbound_emails_controller_test.rb
265
- - test/controllers/ingresses/postfix/inbound_emails_controller_test.rb
266
- - test/controllers/ingresses/sendgrid/inbound_emails_controller_test.rb
267
- - test/dummy/.babelrc
268
- - test/dummy/.gitignore
269
- - test/dummy/.postcssrc.yml
270
- - test/dummy/Rakefile
271
- - test/dummy/app/assets/config/manifest.js
272
- - test/dummy/app/assets/images/.keep
273
- - test/dummy/app/assets/stylesheets/application.css
274
- - test/dummy/app/assets/stylesheets/scaffold.css
275
- - test/dummy/app/channels/application_cable/channel.rb
276
- - test/dummy/app/channels/application_cable/connection.rb
277
- - test/dummy/app/controllers/application_controller.rb
278
- - test/dummy/app/controllers/concerns/.keep
279
- - test/dummy/app/helpers/application_helper.rb
280
- - test/dummy/app/javascript/packs/application.js
281
- - test/dummy/app/jobs/application_job.rb
282
- - test/dummy/app/mailboxes/application_mailbox.rb
283
- - test/dummy/app/mailboxes/messages_mailbox.rb
284
- - test/dummy/app/mailers/application_mailer.rb
285
- - test/dummy/app/models/application_record.rb
286
- - test/dummy/app/models/concerns/.keep
287
- - test/dummy/app/views/layouts/application.html.erb
288
- - test/dummy/app/views/layouts/mailer.html.erb
289
- - test/dummy/app/views/layouts/mailer.text.erb
290
- - test/dummy/bin/bundle
291
- - test/dummy/bin/rails
292
- - test/dummy/bin/rake
293
- - test/dummy/bin/setup
294
- - test/dummy/bin/update
295
- - test/dummy/bin/yarn
296
- - test/dummy/config.ru
297
- - test/dummy/config/application.rb
298
- - test/dummy/config/boot.rb
299
- - test/dummy/config/cable.yml
300
- - test/dummy/config/database.yml
301
- - test/dummy/config/environment.rb
302
- - test/dummy/config/environments/development.rb
303
- - test/dummy/config/environments/production.rb
304
- - test/dummy/config/environments/test.rb
305
- - test/dummy/config/initializers/application_controller_renderer.rb
306
- - test/dummy/config/initializers/assets.rb
307
- - test/dummy/config/initializers/backtrace_silencers.rb
308
- - test/dummy/config/initializers/content_security_policy.rb
309
- - test/dummy/config/initializers/cookies_serializer.rb
310
- - test/dummy/config/initializers/filter_parameter_logging.rb
311
- - test/dummy/config/initializers/inflections.rb
312
- - test/dummy/config/initializers/mime_types.rb
313
- - test/dummy/config/initializers/wrap_parameters.rb
314
- - test/dummy/config/locales/en.yml
315
- - test/dummy/config/puma.rb
316
- - test/dummy/config/routes.rb
317
- - test/dummy/config/spring.rb
318
- - test/dummy/config/storage.yml
319
- - test/dummy/config/webpack/development.js
320
- - test/dummy/config/webpack/environment.js
321
- - test/dummy/config/webpack/production.js
322
- - test/dummy/config/webpack/test.js
323
- - test/dummy/config/webpacker.yml
324
- - test/dummy/db/migrate/20180208205311_create_action_mailroom_tables.rb
325
- - test/dummy/db/migrate/20180212164506_create_active_storage_tables.active_storage.rb
326
- - test/dummy/db/schema.rb
327
- - test/dummy/lib/assets/.keep
328
- - test/dummy/log/.keep
329
- - test/dummy/log/development.log
330
- - test/dummy/package.json
331
- - test/dummy/public/404.html
332
- - test/dummy/public/422.html
333
- - test/dummy/public/500.html
334
- - test/dummy/public/apple-touch-icon-precomposed.png
335
- - test/dummy/public/apple-touch-icon.png
336
- - test/dummy/public/favicon.ico
337
- - test/dummy/storage/.keep
338
- - test/dummy/tmp/.keep
339
- - test/dummy/tmp/storage/.keep
340
- - test/dummy/yarn.lock
341
- - test/fixtures/files/welcome.eml
342
- - test/jobs/incineration_job_test.rb
343
- - test/test_helper.rb
344
- - test/unit/inbound_email/incineration_test.rb
345
- - test/unit/inbound_email/message_id_test.rb
346
- - test/unit/inbound_email_test.rb
347
- - test/unit/mail_ext/address_equality_test.rb
348
- - test/unit/mail_ext/address_wrapping_test.rb
349
- - test/unit/mail_ext/recipients_test.rb
350
- - test/unit/mailbox/bouncing_test.rb
351
- - test/unit/mailbox/callbacks_test.rb
352
- - test/unit/mailbox/routing_test.rb
353
- - test/unit/mailbox/state_test.rb
354
- - test/unit/postfix_relayer_test.rb
355
- - test/unit/router_test.rb
183
+ summary: Inbound email handling framework.
184
+ test_files: []