Skip to content

Instantly share code, notes, and snippets.

@j-manu
Forked from leastbad/action_mailbox.md
Created January 16, 2023 08:35
Show Gist options
  • Save j-manu/ada57a930473c4d25e85e03b5132683d to your computer and use it in GitHub Desktop.
Save j-manu/ada57a930473c4d25e85e03b5132683d to your computer and use it in GitHub Desktop.

Revisions

  1. @leastbad leastbad revised this gist Feb 8, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion incoming_mailbox.rb
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@ class IncomingMailbox < ApplicationMailbox

    # before_processing do
    # unless User.exist?(email: mail.from)
    # bounce_with Mailer.user_not_found(mail).deliver_later
    # bounce_with Mailer.user_not_found(mail)
    # end
    # end

  2. @leastbad leastbad revised this gist Jan 10, 2020. 1 changed file with 5 additions and 4 deletions.
    9 changes: 5 additions & 4 deletions action_mailbox.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    This is all you really need to know in order to make Action Mailbox work in development.

    1. Fire up `ngrok http 3000` and make note of your subdomain for steps 3 and 8.
    2. Create a Mailgun account because they offer sandbox addresses; grab your domain from the Dashboard
    2. Create a Mailgun account because they offer sandbox addresses; grab your domain from the Dashboard.
    3. Go into Receiving and create a catch-all route pointing to: `https://XXX.ngrok.io/rails/action_mailbox/mailgun/inbound_emails/mime`
    4. Add your Mailgun API key to your credentials:

    @@ -21,6 +21,7 @@ action_mailbox:
    ```

    9. Make sure your `config/sidekiq.yml` is monitoring the `action_mailbox_routing` queue.
    10. Configure your `application_mailbox.rb` with whatever routing you need; example below
    11. Configure your `incoming_mailbox.rb` as you wish; example below
    12. You should now be able to send an email to test@MAILGUN-SANDBOX-DOMAIN.
    10. Configure your `application_mailbox.rb` with whatever routing you need; example below.
    11. Configure your `incoming_mailbox.rb` as you wish; example below.

    You should now be able to send an email to test@MAILGUN-SANDBOX-DOMAIN.
  3. @leastbad leastbad revised this gist Jan 10, 2020. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions incoming_mailbox.rb
    Original file line number Diff line number Diff line change
    @@ -9,8 +9,6 @@ class IncomingMailbox < ApplicationMailbox
    # end
    # end

    # NOTE: Make sure sidekiq.yml is processing the action_mailbox_routing queue

    def process
    # puts mail.methods - Object.methods
    # mail.content, mail.subject, mail.has_attachments?
  4. @leastbad leastbad revised this gist Jan 10, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion action_mailbox.md
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ action_mailbox:

    5. `rails action_mailbox:install`
    6. `rake db:migrate`
    7. `rails generate mailbox`
    7. `rails generate mailbox incoming`
    8. Add the following to your `config/environments/development.rb`

    ```
  5. @leastbad leastbad revised this gist Jan 10, 2020. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions action_mailbox.md
    Original file line number Diff line number Diff line change
    @@ -23,3 +23,4 @@ action_mailbox:
    9. Make sure your `config/sidekiq.yml` is monitoring the `action_mailbox_routing` queue.
    10. Configure your `application_mailbox.rb` with whatever routing you need; example below
    11. Configure your `incoming_mailbox.rb` as you wish; example below
    12. You should now be able to send an email to test@MAILGUN-SANDBOX-DOMAIN.
  6. @leastbad leastbad revised this gist Jan 10, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion action_mailbox.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    This is all you really need to know in order to make Action Mailbox work in development.

    1. Fire up `ngrok http 3000` and make note of your subdomain for step 3.
    1. Fire up `ngrok http 3000` and make note of your subdomain for steps 3 and 8.
    2. Create a Mailgun account because they offer sandbox addresses; grab your domain from the Dashboard
    3. Go into Receiving and create a catch-all route pointing to: `https://XXX.ngrok.io/rails/action_mailbox/mailgun/inbound_emails/mime`
    4. Add your Mailgun API key to your credentials:
  7. @leastbad leastbad revised this gist Jan 10, 2020. 1 changed file with 6 additions and 3 deletions.
    9 changes: 6 additions & 3 deletions action_mailbox.md
    Original file line number Diff line number Diff line change
    @@ -7,15 +7,18 @@ This is all you really need to know in order to make Action Mailbox work in deve

    ``` # rails credentials:edit
    action_mailbox:
    mailgun_api_key: API KEY HERE```
    mailgun_api_key: API KEY HERE
    ```

    5. `rails action_mailbox:install`
    6. `rake db:migrate`
    7. `rails generate mailbox`
    8. Add the following to your `config/environments/development.rb`

    ``` config.action_mailbox.ingress = :mailgun
    config.hosts << "XXX.ngrok.io"```
    ```
    config.action_mailbox.ingress = :mailgun
    config.hosts << "XXX.ngrok.io"
    ```

    9. Make sure your `config/sidekiq.yml` is monitoring the `action_mailbox_routing` queue.
    10. Configure your `application_mailbox.rb` with whatever routing you need; example below
  8. @leastbad leastbad created this gist Jan 10, 2020.
    22 changes: 22 additions & 0 deletions action_mailbox.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    This is all you really need to know in order to make Action Mailbox work in development.

    1. Fire up `ngrok http 3000` and make note of your subdomain for step 3.
    2. Create a Mailgun account because they offer sandbox addresses; grab your domain from the Dashboard
    3. Go into Receiving and create a catch-all route pointing to: `https://XXX.ngrok.io/rails/action_mailbox/mailgun/inbound_emails/mime`
    4. Add your Mailgun API key to your credentials:

    ``` # rails credentials:edit
    action_mailbox:
    mailgun_api_key: API KEY HERE```
    5. `rails action_mailbox:install`
    6. `rake db:migrate`
    7. `rails generate mailbox`
    8. Add the following to your `config/environments/development.rb`
    ``` config.action_mailbox.ingress = :mailgun
    config.hosts << "XXX.ngrok.io"```
    9. Make sure your `config/sidekiq.yml` is monitoring the `action_mailbox_routing` queue.
    10. Configure your `application_mailbox.rb` with whatever routing you need; example below
    11. Configure your `incoming_mailbox.rb` as you wish; example below
    4 changes: 4 additions & 0 deletions application_mailbox.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    class ApplicationMailbox < ActionMailbox::Base
    # routing /^info@/i => :incoming
    routing all: :incoming
    end
    19 changes: 19 additions & 0 deletions incoming_mailbox.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    class IncomingMailbox < ApplicationMailbox
    # before_processing
    # around_processing
    # after_processing

    # before_processing do
    # unless User.exist?(email: mail.from)
    # bounce_with Mailer.user_not_found(mail).deliver_later
    # end
    # end

    # NOTE: Make sure sidekiq.yml is processing the action_mailbox_routing queue

    def process
    # puts mail.methods - Object.methods
    # mail.content, mail.subject, mail.has_attachments?
    puts mail.inspect
    end
    end