actionmailbox 6.0.6.1 → 6.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d00281a6983c176229ac802d85296f5c4e4b0f5d660f40b0691bb663d670e83
4
- data.tar.gz: af54f053968f0641a2d6e6e5dae9551ba7897a03dff4abfa429cfd3628ee4109
3
+ metadata.gz: 250cbc428fc9ad9c9ba5227a22e478dab77c129428e9ac335878ce834e7f24d1
4
+ data.tar.gz: b8835f730cebb308a96d9e1aa8a0d19d1c7d2af6fe9be79c8411a17b72f7a2f1
5
5
  SHA512:
6
- metadata.gz: f56a3f0e48b5c34335d49523ad6f2bdeacf8cafac042c19174a504bf2065b74f66c4b086aaff96780c61032855918a3bc0b914d3434ef5ad1e714e6268d9a5c8
7
- data.tar.gz: db4dc8e66f36e674393335737d121c1746fafb0f0bde99034fad306c689d954fa394928a57d4957cde3eae606324a2879e9577598ec943b2fda268b4d185040b
6
+ metadata.gz: b99940a3413d02da761a105b99538d11e70e33a7fa11689b45425769f130dea79001ab4b557b8469a1c7aed01e52e90b895ee26f0a1bbd8e006134cac33435c9
7
+ data.tar.gz: e844914ff9fa3a69ee3473b2647c81f2def522fdaa6c107ad668def4546ef405bd2452a24ddede27d8d70e7072c2f43c369c9981a551245d75aec1624e7d1d4d
data/CHANGELOG.md CHANGED
@@ -1,163 +1,36 @@
1
- ## Rails 6.0.6.1 (January 17, 2023) ##
1
+ ## Rails 6.1.0.rc1 (November 02, 2020) ##
2
2
 
3
- * No changes.
3
+ * Sendgrid ingress now passes through the envelope recipient as `X-Original-To`.
4
4
 
5
-
6
- ## Rails 6.0.6 (September 09, 2022) ##
7
-
8
- * No changes.
9
-
10
-
11
- ## Rails 6.0.5.1 (July 12, 2022) ##
12
-
13
- * No changes.
14
-
15
-
16
- ## Rails 6.0.5 (May 09, 2022) ##
17
-
18
- * No changes.
19
-
20
-
21
- ## Rails 6.0.4.8 (April 26, 2022) ##
22
-
23
- * No changes.
24
-
25
-
26
- ## Rails 6.0.4.7 (March 08, 2022) ##
27
-
28
- * No changes.
29
-
30
-
31
- ## Rails 6.0.4.6 (February 11, 2022) ##
32
-
33
- * No changes.
34
-
35
-
36
- ## Rails 6.0.4.5 (February 11, 2022) ##
37
-
38
- * No changes.
39
-
40
-
41
- ## Rails 6.0.4.4 (December 15, 2021) ##
42
-
43
- * No changes.
44
-
45
-
46
- ## Rails 6.0.4.3 (December 14, 2021) ##
47
-
48
- * No changes.
49
-
50
-
51
- ## Rails 6.0.4.2 (December 14, 2021) ##
52
-
53
- * No changes.
54
-
55
-
56
- ## Rails 6.0.4.1 (August 19, 2021) ##
57
-
58
- * No changes.
59
-
60
-
61
- ## Rails 6.0.4 (June 15, 2021) ##
62
-
63
- * No changes.
64
-
65
-
66
- ## Rails 6.0.3.7 (May 05, 2021) ##
67
-
68
- * No changes.
69
-
70
-
71
- ## Rails 6.0.3.6 (March 26, 2021) ##
72
-
73
- * No changes.
74
-
75
-
76
- ## Rails 6.0.3.5 (February 10, 2021) ##
77
-
78
- * No changes.
79
-
80
-
81
- ## Rails 6.0.3.4 (October 07, 2020) ##
82
-
83
- * No changes.
84
-
85
-
86
- ## Rails 6.0.3.3 (September 09, 2020) ##
87
-
88
- * No changes.
89
-
90
-
91
- ## Rails 6.0.3.2 (June 17, 2020) ##
92
-
93
- * No changes.
94
-
95
-
96
- ## Rails 6.0.3.1 (May 18, 2020) ##
97
-
98
- * No changes.
99
-
100
-
101
- ## Rails 6.0.3 (May 06, 2020) ##
5
+ *Mark Haussmann*
102
6
 
103
7
  * Update Mandrill inbound email route to respond appropriately to HEAD requests for URL health checks from Mandrill.
104
8
 
105
9
  *Bill Cromie*
106
10
 
11
+ * Add way to deliver emails via source instead of filling out a form through the conductor interface.
107
12
 
108
- ## Rails 6.0.2.2 (March 19, 2020) ##
109
-
110
- * No changes.
111
-
112
-
113
- ## Rails 6.0.2.1 (December 18, 2019) ##
114
-
115
- * No changes.
116
-
117
-
118
- ## Rails 6.0.2 (December 13, 2019) ##
13
+ *DHH*
119
14
 
120
- * No changes.
15
+ * Mailgun ingress now passes through the envelope recipient as `X-Original-To`.
121
16
 
17
+ *Rikki Pitt*
122
18
 
123
- ## Rails 6.0.1 (November 5, 2019) ##
19
+ * Deprecate `Rails.application.credentials.action_mailbox.api_key` and `MAILGUN_INGRESS_API_KEY` in favor of `Rails.application.credentials.action_mailbox.signing_key` and `MAILGUN_INGRESS_SIGNING_KEY`.
124
20
 
125
- * No changes.
21
+ *Matthijs Vos*
126
22
 
23
+ * Allow easier creation of multi-part emails from the `create_inbound_email_from_mail` and `receive_inbound_email_from_mail` test helpers.
127
24
 
128
- ## Rails 6.0.0 (August 16, 2019) ##
25
+ *Michael Herold*
129
26
 
130
27
  * Fix Bcc header not being included with emails from `create_inbound_email_from` test helpers.
131
28
 
132
29
  *jduff*
133
30
 
31
+ * Add `ApplicationMailbox.mailbox_for` to expose mailbox routing.
134
32
 
135
- ## Rails 6.0.0.rc2 (July 22, 2019) ##
136
-
137
- * No changes.
138
-
139
-
140
- ## Rails 6.0.0.rc1 (April 24, 2019) ##
141
-
142
- * No changes.
143
-
33
+ *James Dabbs*
144
34
 
145
- ## Rails 6.0.0.beta3 (March 11, 2019) ##
146
35
 
147
- * No changes.
148
-
149
-
150
- ## Rails 6.0.0.beta2 (February 25, 2019) ##
151
-
152
- * Allow skipping incineration of processed emails.
153
-
154
- This can be done by setting `config.action_mailbox.incinerate` to `false`.
155
-
156
- *Pratik Naik*
157
-
158
-
159
- ## Rails 6.0.0.beta1 (January 18, 2019) ##
160
-
161
- * Added to Rails.
162
-
163
- *DHH*
36
+ Please check [6-0-stable](https://github.com/rails/rails/blob/6-0-stable/actionmailbox/CHANGELOG.md) for previous changes.
data/MIT-LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2019 Basecamp, LLC
3
+ Copyright (c) 2018-2020 Basecamp, LLC
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -6,7 +6,7 @@ module ActionMailbox
6
6
  # - +body-mime+: The full RFC 822 message
7
7
  # - +timestamp+: The current time according to Mailgun as the number of seconds passed since the UNIX epoch
8
8
  # - +token+: A randomly-generated, 50-character string
9
- # - +signature+: A hexadecimal HMAC-SHA256 of the timestamp concatenated with the token, generated using the Mailgun API key
9
+ # - +signature+: A hexadecimal HMAC-SHA256 of the timestamp concatenated with the token, generated using the Mailgun Signing key
10
10
  #
11
11
  # Authenticates requests by validating their signatures.
12
12
  #
@@ -16,21 +16,21 @@ module ActionMailbox
16
16
  # - <tt>401 Unauthorized</tt> if the request's signature could not be validated, or if its timestamp is more than 2 minutes old
17
17
  # - <tt>404 Not Found</tt> if Action Mailbox is not configured to accept inbound emails from Mailgun
18
18
  # - <tt>422 Unprocessable Entity</tt> if the request is missing required parameters
19
- # - <tt>500 Server Error</tt> if the Mailgun API key is missing, or one of the Active Record database,
19
+ # - <tt>500 Server Error</tt> if the Mailgun Signing key is missing, or one of the Active Record database,
20
20
  # the Active Storage service, or the Active Job backend is misconfigured or unavailable
21
21
  #
22
22
  # == Usage
23
23
  #
24
- # 1. Give Action Mailbox your {Mailgun API key}[https://help.mailgun.com/hc/en-us/articles/203380100-Where-can-I-find-my-API-key-and-SMTP-credentials-]
24
+ # 1. Give Action Mailbox your Mailgun Signing key (which you can find under Settings -> Security & Users -> API security in Mailgun)
25
25
  # so it can authenticate requests to the Mailgun ingress.
26
26
  #
27
- # Use <tt>rails credentials:edit</tt> to add your API key to your application's encrypted credentials under
28
- # +action_mailbox.mailgun_api_key+, where Action Mailbox will automatically find it:
27
+ # Use <tt>bin/rails credentials:edit</tt> to add your Signing key to your application's encrypted credentials under
28
+ # +action_mailbox.mailgun_signing_key+, where Action Mailbox will automatically find it:
29
29
  #
30
30
  # action_mailbox:
31
- # mailgun_api_key: ...
31
+ # mailgun_signing_key: ...
32
32
  #
33
- # Alternatively, provide your API key in the +MAILGUN_INGRESS_API_KEY+ environment variable.
33
+ # Alternatively, provide your Signing key in the +MAILGUN_INGRESS_SIGNING_KEY+ environment variable.
34
34
  #
35
35
  # 2. Tell Action Mailbox to accept emails from Mailgun:
36
36
  #
@@ -46,10 +46,16 @@ module ActionMailbox
46
46
  before_action :authenticate
47
47
 
48
48
  def create
49
- ActionMailbox::InboundEmail.create_and_extract_message_id! params.require("body-mime")
49
+ ActionMailbox::InboundEmail.create_and_extract_message_id! mail
50
50
  end
51
51
 
52
52
  private
53
+ def mail
54
+ params.require("body-mime").tap do |raw_email|
55
+ raw_email.prepend("X-Original-To: ", params.require(:recipient), "\n") if params.key?(:recipient)
56
+ end
57
+ end
58
+
53
59
  def authenticate
54
60
  head :unauthorized unless authenticated?
55
61
  end
@@ -64,14 +70,28 @@ module ActionMailbox
64
70
  ).authenticated?
65
71
  else
66
72
  raise ArgumentError, <<~MESSAGE.squish
67
- Missing required Mailgun API key. Set action_mailbox.mailgun_api_key in your application's
68
- encrypted credentials or provide the MAILGUN_INGRESS_API_KEY environment variable.
73
+ Missing required Mailgun Signing key. Set action_mailbox.mailgun_signing_key in your application's
74
+ encrypted credentials or provide the MAILGUN_INGRESS_SIGNING_KEY environment variable.
69
75
  MESSAGE
70
76
  end
71
77
  end
72
78
 
73
79
  def key
74
- Rails.application.credentials.dig(:action_mailbox, :mailgun_api_key) || ENV["MAILGUN_INGRESS_API_KEY"]
80
+ if Rails.application.credentials.dig(:action_mailbox, :mailgun_api_key)
81
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
82
+ Rails.application.credentials.action_mailbox.api_key is deprecated and will be ignored in Rails 6.2.
83
+ Use Rails.application.credentials.action_mailbox.signing_key instead.
84
+ MSG
85
+ Rails.application.credentials.dig(:action_mailbox, :mailgun_api_key)
86
+ elsif ENV["MAILGUN_INGRESS_API_KEY"]
87
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
88
+ The MAILGUN_INGRESS_API_KEY environment variable is deprecated and will be ignored in Rails 6.2.
89
+ Use MAILGUN_INGRESS_SIGNING_KEY instead.
90
+ MSG
91
+ ENV["MAILGUN_INGRESS_API_KEY"]
92
+ else
93
+ Rails.application.credentials.dig(:action_mailbox, :mailgun_signing_key) || ENV["MAILGUN_INGRESS_SIGNING_KEY"]
94
+ end
75
95
  end
76
96
 
77
97
  class Authenticator
@@ -27,7 +27,7 @@ module ActionMailbox
27
27
  #
28
28
  # 2. Generate a strong password that Action Mailbox can use to authenticate requests to the Postmark ingress.
29
29
  #
30
- # Use <tt>rails credentials:edit</tt> to add the password to your application's encrypted credentials under
30
+ # Use <tt>bin/rails credentials:edit</tt> to add the password to your application's encrypted credentials under
31
31
  # +action_mailbox.ingress_password+, where Action Mailbox will automatically find it:
32
32
  #
33
33
  # action_mailbox:
@@ -27,7 +27,7 @@ module ActionMailbox
27
27
  #
28
28
  # 2. Generate a strong password that Action Mailbox can use to authenticate requests to the ingress.
29
29
  #
30
- # Use <tt>rails credentials:edit</tt> to add the password to your application's encrypted credentials under
30
+ # Use <tt>bin/rails credentials:edit</tt> to add the password to your application's encrypted credentials under
31
31
  # +action_mailbox.ingress_password+, where Action Mailbox will automatically find it:
32
32
  #
33
33
  # action_mailbox:
@@ -27,7 +27,7 @@ module ActionMailbox
27
27
  #
28
28
  # 2. Generate a strong password that Action Mailbox can use to authenticate requests to the SendGrid ingress.
29
29
  #
30
- # Use <tt>rails credentials:edit</tt> to add the password to your application's encrypted credentials under
30
+ # Use <tt>bin/rails credentials:edit</tt> to add the password to your application's encrypted credentials under
31
31
  # +action_mailbox.ingress_password+, where Action Mailbox will automatically find it:
32
32
  #
33
33
  # action_mailbox:
@@ -48,7 +48,21 @@ module ActionMailbox
48
48
  before_action :authenticate_by_password
49
49
 
50
50
  def create
51
- ActionMailbox::InboundEmail.create_and_extract_message_id! params.require(:email)
51
+ ActionMailbox::InboundEmail.create_and_extract_message_id! mail
52
+ rescue JSON::ParserError => error
53
+ logger.error error.message
54
+ head :unprocessable_entity
52
55
  end
56
+
57
+ private
58
+ def mail
59
+ params.require(:email).tap do |raw_email|
60
+ envelope["to"].each { |to| raw_email.prepend("X-Original-To: ", to, "\n") } if params.key?(:envelope)
61
+ end
62
+ end
63
+
64
+ def envelope
65
+ JSON.parse(params.require(:envelope))
66
+ end
53
67
  end
54
68
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rails
4
+ class Conductor::ActionMailbox::InboundEmails::SourcesController < Rails::Conductor::BaseController
5
+ def new
6
+ end
7
+
8
+ def create
9
+ inbound_email = ActionMailbox::InboundEmail.create_and_extract_message_id! params[:source]
10
+ redirect_to main_app.rails_conductor_inbound_email_url(inbound_email)
11
+ end
12
+ end
13
+ end
@@ -20,7 +20,7 @@ module Rails
20
20
 
21
21
  private
22
22
  def new_mail
23
- Mail.new(params.require(:mail).permit(:from, :to, :cc, :bcc, :in_reply_to, :subject, :body).to_h).tap do |mail|
23
+ Mail.new(params.require(:mail).permit(:from, :to, :cc, :bcc, :x_original_to, :in_reply_to, :subject, :body).to_h).tap do |mail|
24
24
  mail[:bcc]&.include_in_headers = true
25
25
  params[:mail][:attachments].to_a.each do |attachment|
26
26
  mail.add_file(filename: attachment.original_filename, content: attachment.read)
@@ -10,7 +10,7 @@ module ActionMailbox::InboundEmail::MessageId
10
10
  extend ActiveSupport::Concern
11
11
 
12
12
  class_methods do
13
- # Create a new +InboundEmail+ from the raw +source+ of the email, which be uploaded as a Active Storage
13
+ # Create a new +InboundEmail+ from the raw +source+ of the email, which is uploaded as an Active Storage
14
14
  # attachment called +raw_email+. Before the upload, extract the Message-ID from the +source+ and set
15
15
  # it as an attribute on the new +InboundEmail+.
16
16
  def create_and_extract_message_id!(source, **options)
@@ -24,7 +24,7 @@ module ActionMailbox
24
24
  #
25
25
  # inbound_email.mail.from # => 'david@loudthinking.com'
26
26
  # inbound_email.source # Returns the full rfc822 source of the email as text
27
- class InboundEmail < ActiveRecord::Base
27
+ class InboundEmail < Record
28
28
  self.table_name = "action_mailbox_inbound_emails"
29
29
 
30
30
  include Incineratable, MessageId, Routable
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionMailbox
4
+ class Record < ActiveRecord::Base #:nodoc:
5
+ self.abstract_class = true
6
+ end
7
+ end
8
+
9
+ ActiveSupport.run_load_hooks :action_mailbox_record, ActionMailbox::Record
@@ -12,4 +12,5 @@
12
12
  <% end %>
13
13
  </table>
14
14
 
15
- <%= link_to "Deliver new inbound email", main_app.new_rails_conductor_inbound_email_path %>
15
+ <%= link_to "New inbound email by form", main_app.new_rails_conductor_inbound_email_path %> |
16
+ <%= link_to "New inbound email by source", main_app.new_rails_conductor_inbound_email_source_path %>
@@ -5,37 +5,42 @@
5
5
  <%= form_with(url: main_app.rails_conductor_inbound_emails_path, scope: :mail, local: true) do |form| %>
6
6
  <div>
7
7
  <%= form.label :from, "From" %><br>
8
- <%= form.text_field :from %>
8
+ <%= form.text_field :from, value: params[:from] %>
9
9
  </div>
10
10
 
11
11
  <div>
12
12
  <%= form.label :to, "To" %><br>
13
- <%= form.text_field :to %>
13
+ <%= form.text_field :to, value: params[:to] %>
14
14
  </div>
15
15
 
16
16
  <div>
17
17
  <%= form.label :cc, "CC" %><br>
18
- <%= form.text_field :cc %>
18
+ <%= form.text_field :cc, value: params[:cc] %>
19
19
  </div>
20
20
 
21
21
  <div>
22
22
  <%= form.label :bcc, "BCC" %><br>
23
- <%= form.text_field :bcc %>
23
+ <%= form.text_field :bcc, value: params[:bcc] %>
24
+ </div>
25
+
26
+ <div>
27
+ <%= form.label :x_original_to, "X-Original-To" %><br>
28
+ <%= form.text_field :x_original_to, value: params[:x_original_to] %>
24
29
  </div>
25
30
 
26
31
  <div>
27
32
  <%= form.label :in_reply_to, "In-Reply-To" %><br>
28
- <%= form.text_field :in_reply_to %>
33
+ <%= form.text_field :in_reply_to, value: params[:in_reply_to] %>
29
34
  </div>
30
35
 
31
36
  <div>
32
37
  <%= form.label :subject, "Subject" %><br>
33
- <%= form.text_field :subject %>
38
+ <%= form.text_field :subject, value: params[:subject] %>
34
39
  </div>
35
40
 
36
41
  <div>
37
42
  <%= form.label :body, "Body" %><br>
38
- <%= form.text_area :body, size: "40x20" %>
43
+ <%= form.text_area :body, size: "40x20", value: params[:body] %>
39
44
  </div>
40
45
 
41
46
  <div>
@@ -0,0 +1,12 @@
1
+ <% provide :title, "Deliver new inbound email by source" %>
2
+
3
+ <h1>Deliver new inbound email by source</h1>
4
+
5
+ <%= form_with(url: main_app.rails_conductor_inbound_email_sources_path, local: true) do |form| %>
6
+ <div>
7
+ <%= form.label :source, "Source" %><br>
8
+ <%= form.text_area :source, size: "80x60" %>
9
+ </div>
10
+
11
+ <%= form.submit "Deliver inbound email" %>
12
+ <% end %>
data/config/routes.rb CHANGED
@@ -17,6 +17,9 @@ Rails.application.routes.draw do
17
17
  # TODO: Should these be mounted within the engine only?
18
18
  scope "rails/conductor/action_mailbox/", module: "rails/conductor/action_mailbox" do
19
19
  resources :inbound_emails, as: :rails_conductor_inbound_emails
20
+ get "inbound_emails/sources/new", to: "inbound_emails/sources#new", as: :new_rails_conductor_inbound_email_source
21
+ post "inbound_emails/sources", to: "inbound_emails/sources#create", as: :rails_conductor_inbound_email_sources
22
+
20
23
  post ":inbound_email_id/reroute" => "reroutes#create", as: :rails_conductor_inbound_email_reroute
21
24
  end
22
25
  end
@@ -8,9 +8,9 @@ module ActionMailbox
8
8
 
9
9
  module VERSION
10
10
  MAJOR = 6
11
- MINOR = 0
12
- TINY = 6
13
- PRE = "1"
11
+ MINOR = 1
12
+ TINY = 0
13
+ PRE = "rc1"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -21,7 +21,7 @@ module ActionMailbox
21
21
  end
22
22
 
23
23
  def route(inbound_email)
24
- if mailbox = match_to_mailbox(inbound_email)
24
+ if mailbox = mailbox_for(inbound_email)
25
25
  mailbox.receive(inbound_email)
26
26
  else
27
27
  inbound_email.bounced!
@@ -30,12 +30,12 @@ module ActionMailbox
30
30
  end
31
31
  end
32
32
 
33
+ def mailbox_for(inbound_email)
34
+ routes.detect { |route| route.match?(inbound_email) }&.mailbox_class
35
+ end
36
+
33
37
  private
34
38
  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
39
  end
40
40
  end
41
41
 
@@ -17,6 +17,10 @@ module ActionMailbox
17
17
  def route(inbound_email)
18
18
  router.route(inbound_email)
19
19
  end
20
+
21
+ def mailbox_for(inbound_email)
22
+ router.mailbox_for(inbound_email)
23
+ end
20
24
  end
21
25
  end
22
26
  end
@@ -10,11 +10,58 @@ module ActionMailbox
10
10
  create_inbound_email_from_source file_fixture(fixture_name).read, status: status
11
11
  end
12
12
 
13
- # Create an +InboundEmail+ by specifying it using +Mail.new+ options. Example:
13
+ # Creates an +InboundEmail+ by specifying through options or a block.
14
+ #
15
+ # ==== Options
16
+ #
17
+ # * <tt>:status</tt> - The +status+ to set for the created +InboundEmail+.
18
+ # For possible statuses, see {its documentation}[rdoc-ref:ActionMailbox::InboundEmail].
19
+ #
20
+ # ==== Creating a simple email
21
+ #
22
+ # When you only need to set basic fields like +from+, +to+, +subject+, and
23
+ # +body+, you can pass them directly as options.
14
24
  #
15
25
  # create_inbound_email_from_mail(from: "david@loudthinking.com", subject: "Hello!")
16
- def create_inbound_email_from_mail(status: :processing, **mail_options)
17
- mail = Mail.new(mail_options)
26
+ #
27
+ # ==== Creating a multi-part email
28
+ #
29
+ # When you need to create a more intricate email, like a multi-part email
30
+ # that contains both a plaintext version and an HTML version, you can pass a
31
+ # block.
32
+ #
33
+ # create_inbound_email_from_mail do
34
+ # to "David Heinemeier Hansson <david@loudthinking.com>"
35
+ # from "Bilbo Baggins <bilbo@bagend.com>"
36
+ # subject "Come down to the Shire!"
37
+ #
38
+ # text_part do
39
+ # body "Please join us for a party at Bag End"
40
+ # end
41
+ #
42
+ # html_part do
43
+ # body "<h1>Please join us for a party at Bag End</h1>"
44
+ # end
45
+ # end
46
+ #
47
+ # As with +Mail.new+, you can also use a block parameter to define the parts
48
+ # of the message:
49
+ #
50
+ # create_inbound_email_from_mail do |mail|
51
+ # mail.to "David Heinemeier Hansson <david@loudthinking.com>"
52
+ # mail.from "Bilbo Baggins <bilbo@bagend.com>"
53
+ # mail.subject "Come down to the Shire!"
54
+ #
55
+ # mail.text_part do |part|
56
+ # part.body "Please join us for a party at Bag End"
57
+ # end
58
+ #
59
+ # mail.html_part do |part|
60
+ # part.body "<h1>Please join us for a party at Bag End</h1>"
61
+ # end
62
+ # end
63
+ def create_inbound_email_from_mail(status: :processing, **mail_options, &block)
64
+ mail = Mail.new(mail_options, &block)
18
65
  # Bcc header is not encoded by default
19
66
  mail[:bcc].include_in_headers = true if mail[:bcc]
20
67
 
@@ -33,10 +80,11 @@ module ActionMailbox
33
80
  create_inbound_email_from_fixture(*args).tap(&:route)
34
81
  end
35
82
 
36
- # Create an +InboundEmail+ using the same arguments as +create_inbound_email_from_mail+ and immediately route it to
37
- # processing.
38
- def receive_inbound_email_from_mail(**kwargs)
39
- create_inbound_email_from_mail(**kwargs).tap(&:route)
83
+ # Create an +InboundEmail+ using the same options or block as
84
+ # {create_inbound_email_from_mail}[rdoc-ref:#create_inbound_email_from_mail],
85
+ # then immediately route it for processing.
86
+ def receive_inbound_email_from_mail(**kwargs, &block)
87
+ create_inbound_email_from_mail(**kwargs, &block).tap(&:route)
40
88
  end
41
89
 
42
90
  # Create an +InboundEmail+ using the same arguments as +create_inbound_email_from_source+ and immediately route it
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators/mailbox/mailbox_generator"
4
+
5
+ module ActionMailbox
6
+ module Generators
7
+ class InstallGenerator < ::Rails::Generators::Base
8
+ source_root Rails::Generators::MailboxGenerator.source_root
9
+
10
+ def create_action_mailbox_files
11
+ say "Copying application_mailbox.rb to app/mailboxes", :green
12
+ template "application_mailbox.rb", "app/mailboxes/application_mailbox.rb"
13
+ end
14
+
15
+ def add_action_mailbox_production_environment_config
16
+ environment <<~end_of_config, env: "production"
17
+ # Prepare the ingress controller used to receive mail
18
+ # config.action_mailbox.ingress = :relay
19
+
20
+ end_of_config
21
+ end
22
+
23
+ def create_migrations
24
+ rails_command "railties:install:migrations FROM=active_storage,action_mailbox", inline: true
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,12 +1,12 @@
1
1
  Description:
2
2
  ============
3
- Stubs out a new mailbox class in app/mailboxes and invokes your template
3
+ Generates a new mailbox class in app/mailboxes and invokes your template
4
4
  engine and test framework generators.
5
5
 
6
6
  Example:
7
7
  ========
8
- rails generate mailbox inbox
8
+ bin/rails generate mailbox inbox
9
9
 
10
- creates a InboxMailbox class and test:
10
+ creates an InboxMailbox class and test:
11
11
  Mailbox: app/mailboxes/inbox_mailbox.rb
12
12
  Test: test/mailboxes/inbox_mailbox_test.rb
@@ -1,20 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- namespace :action_mailbox do
4
- # Prevent migration installation task from showing up twice.
5
- Rake::Task["install:migrations"].clear_comments
6
-
7
- desc "Copy over the migration"
8
- task install: %w[ environment run_installer copy_migrations ]
9
-
10
- task :run_installer do
11
- installer_template = File.expand_path("../rails/generators/installer.rb", __dir__)
12
- system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{installer_template}"
13
- end
14
-
15
- task :copy_migrations do
16
- Rake::Task["active_storage:install:migrations"].invoke
17
- Rake::Task["railties:install:migrations"].reenable # Otherwise you can't run 2 migration copy tasks in one invocation
18
- Rake::Task["action_mailbox:install:migrations"].invoke
19
- end
3
+ desc "Installs Action Mailbox and its dependencies"
4
+ task "action_mailbox:install" do
5
+ Rails::Command.invoke :generate, ["action_mailbox:install"]
20
6
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionmailbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.6.1
4
+ version: 6.1.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  - George Claghorn
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-01-17 00:00:00.000000000 Z
12
+ date: 2020-11-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -17,70 +17,70 @@ dependencies:
17
17
  requirements:
18
18
  - - '='
19
19
  - !ruby/object:Gem::Version
20
- version: 6.0.6.1
20
+ version: 6.1.0.rc1
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: 6.0.6.1
27
+ version: 6.1.0.rc1
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: activerecord
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - '='
33
33
  - !ruby/object:Gem::Version
34
- version: 6.0.6.1
34
+ version: 6.1.0.rc1
35
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: 6.0.6.1
41
+ version: 6.1.0.rc1
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: activestorage
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - '='
47
47
  - !ruby/object:Gem::Version
48
- version: 6.0.6.1
48
+ version: 6.1.0.rc1
49
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: 6.0.6.1
55
+ version: 6.1.0.rc1
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: activejob
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - '='
61
61
  - !ruby/object:Gem::Version
62
- version: 6.0.6.1
62
+ version: 6.1.0.rc1
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - '='
68
68
  - !ruby/object:Gem::Version
69
- version: 6.0.6.1
69
+ version: 6.1.0.rc1
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: actionpack
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - '='
75
75
  - !ruby/object:Gem::Version
76
- version: 6.0.6.1
76
+ version: 6.1.0.rc1
77
77
  type: :runtime
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - '='
82
82
  - !ruby/object:Gem::Version
83
- version: 6.0.6.1
83
+ version: 6.1.0.rc1
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: mail
86
86
  requirement: !ruby/object:Gem::Requirement
@@ -112,6 +112,7 @@ files:
112
112
  - app/controllers/action_mailbox/ingresses/postmark/inbound_emails_controller.rb
113
113
  - app/controllers/action_mailbox/ingresses/relay/inbound_emails_controller.rb
114
114
  - app/controllers/action_mailbox/ingresses/sendgrid/inbound_emails_controller.rb
115
+ - app/controllers/rails/conductor/action_mailbox/inbound_emails/sources_controller.rb
115
116
  - app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb
116
117
  - app/controllers/rails/conductor/action_mailbox/reroutes_controller.rb
117
118
  - app/controllers/rails/conductor/base_controller.rb
@@ -122,10 +123,12 @@ files:
122
123
  - app/models/action_mailbox/inbound_email/incineratable/incineration.rb
123
124
  - app/models/action_mailbox/inbound_email/message_id.rb
124
125
  - app/models/action_mailbox/inbound_email/routable.rb
126
+ - app/models/action_mailbox/record.rb
125
127
  - app/views/layouts/rails/conductor.html.erb
126
128
  - app/views/rails/conductor/action_mailbox/inbound_emails/index.html.erb
127
129
  - app/views/rails/conductor/action_mailbox/inbound_emails/new.html.erb
128
130
  - app/views/rails/conductor/action_mailbox/inbound_emails/show.html.erb
131
+ - app/views/rails/conductor/action_mailbox/inbound_emails/sources/new.html.erb
129
132
  - config/routes.rb
130
133
  - db/migrate/20180917164000_create_action_mailbox_tables.rb
131
134
  - lib/action_mailbox.rb
@@ -146,7 +149,7 @@ files:
146
149
  - lib/action_mailbox/test_case.rb
147
150
  - lib/action_mailbox/test_helper.rb
148
151
  - lib/action_mailbox/version.rb
149
- - lib/rails/generators/installer.rb
152
+ - lib/generators/action_mailbox/install/install_generator.rb
150
153
  - lib/rails/generators/mailbox/USAGE
151
154
  - lib/rails/generators/mailbox/mailbox_generator.rb
152
155
  - lib/rails/generators/mailbox/templates/application_mailbox.rb.tt
@@ -160,12 +163,11 @@ licenses:
160
163
  - MIT
161
164
  metadata:
162
165
  bug_tracker_uri: https://github.com/rails/rails/issues
163
- changelog_uri: https://github.com/rails/rails/blob/v6.0.6.1/actionmailbox/CHANGELOG.md
164
- documentation_uri: https://api.rubyonrails.org/v6.0.6.1/
166
+ changelog_uri: https://github.com/rails/rails/blob/v6.1.0.rc1/actionmailbox/CHANGELOG.md
167
+ documentation_uri: https://api.rubyonrails.org/v6.1.0.rc1/
165
168
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
166
- source_code_uri: https://github.com/rails/rails/tree/v6.0.6.1/actionmailbox
167
- rubygems_mfa_required: 'true'
168
- post_install_message:
169
+ source_code_uri: https://github.com/rails/rails/tree/v6.1.0.rc1/actionmailbox
170
+ post_install_message:
169
171
  rdoc_options: []
170
172
  require_paths:
171
173
  - lib
@@ -176,12 +178,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
176
178
  version: 2.5.0
177
179
  required_rubygems_version: !ruby/object:Gem::Requirement
178
180
  requirements:
179
- - - ">="
181
+ - - ">"
180
182
  - !ruby/object:Gem::Version
181
- version: '0'
183
+ version: 1.3.1
182
184
  requirements: []
183
- rubygems_version: 3.4.3
184
- signing_key:
185
+ rubygems_version: 3.1.4
186
+ signing_key:
185
187
  specification_version: 4
186
188
  summary: Inbound email handling framework.
187
189
  test_files: []
@@ -1,10 +0,0 @@
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 = :relay
9
-
10
- end_of_config