GitXplorerGitXplorer
a

aws-actionmailbox-ses-ruby

public
1 stars
1 forks
0 issues

Commits

List of commits on branch main.
Unverified
0a70e3e3248f571dd48747c1e61f218e16cbbe71

Regenerate schema and cert

mmullermp committed 2 months ago
Unverified
6d1ec257be9228c6b713eaceac2a7a8c9bbd2eb0

Added next release section to the changelog. [ci skip]

mmullermp committed 2 months ago
Unverified
3086dedabc55b25895bfb6eff1dba7d8af984778

Bumped version to v0.1.0

mmullermp committed 2 months ago
Unverified
2dc7e071ee44e4dab8a934c1498947d69cdd9a94

Fix Gemfile

mmullermp committed 2 months ago
Unverified
36634d976fc9c122a570311ffa3c0832700b642b

Try different sqlite3 versions

mmullermp committed 2 months ago
Unverified
6f041c2a3068b3d3784934abd12992c5d222703d

Improve CI for release

mmullermp committed 2 months ago

README

The README file for this repository.

Amazon Simple Email Service (SES) as an ActionMailbox Ingress

Gem Version Build Status Github forks Github stars

This gem contains an ActionMailbox ingress using Amazon SES, SNS, and S3.

Installation

Add this gem to your Rails project's Gemfile:

gem 'aws-sdk-rails', '~> 5'
gem 'aws-actionmailbox-ses', '~> 0'

Then run bundle install.

This gem also brings in the following AWS gems:

  • aws-sdk-s3
  • aws-sdk-sns

You will have to ensure that you provide credentials for the SDK to use. See the latest AWS SDK for Ruby Docs for details.

If you're running your Rails application on Amazon EC2, the AWS SDK will check Amazon EC2 instance metadata for credentials to load. Learn more: IAM Roles for Amazon EC2

Configuration

Amazon SES/SNS

  1. Configure SES to save emails to S3 or to send them as raw messages.

  2. Configure the SNS topic for SES or for the S3 action to send notifications to +/rails/action_mailbox/ses/inbound_emails+. For example, if your website is hosted at https://www.example.com then configure SNS to publish the SES notification topic to this HTTP endpoint: https://example.com/rails/action_mailbox/ses/inbound_emails

Rails

  1. Configure ActionMailbox to accept emails from Amazon SES:

    # config/environments/production.rb
    config.action_mailbox.ingress = :ses
  2. Configure which SNS topic will be accepted and what region.

    Note: The bucket's region, which stores the emails, does not need to match the SNS topic's region.

    # config/environments/production.rb
    config.action_mailbox.ses.subscribed_topic = 'arn:aws:sns:us-west-2:012345678910:example-topic-1'
    config.action_mailbox.ses.s3_client_options = { region: 'us-east-1' }

SNS Subscriptions will now be auto-confirmed and messages will be automatically handled via ActionMailbox.

Note: Even if you manually confirm subscriptions, you will still need to provide a list of subscribed topics; messages from unrecognized topics will be ignored.

See ActionMailbox documentation for full usage information.

Testing

Two RSpec request spec helpers are provided to facilitate testing Amazon SNS/SES notifications in your application:

  • action_mailbox_ses_deliver_subscription_confirmation
  • action_mailbox_ses_deliver_email

Include the Aws::ActionMailbox::SES::RSpec extension in your tests:

# spec/rails_helper.rb

require 'aws/action_mailbox/ses/rspec'

RSpec.configure do |config|
  config.include Aws::ActionMailbox::SES::RSpec
end

Configure your test environment to accept the default topic used by the provided helpers:

# config/environments/test.rb
config.action_mailbox.ses.subscribed_topic = 'topic:arn:default'

Example Usage

# spec/requests/amazon_emails_spec.rb
RSpec.describe 'amazon emails', type: :request do
  it 'delivers a subscription notification' do
    action_mailbox_ses_deliver_subscription_confirmation
    expect(response).to have_http_status :ok
  end

  it 'delivers an email notification' do
    action_mailbox_ses_deliver_email(mail: Mail.new(to: 'user@example.com'))
    expect(ActionMailbox::InboundEmail.last.mail.recipients).to eql ['user@example.com']
  end
end

You may also pass the following keyword arguments to both helpers:

  • topic: The SNS topic used for each notification (default: topic:arn:default).
  • authentic: The Aws::SNS::MessageVerifier class is stubbed by these helpers; set authentic to true or false to define how it will verify incoming notifications (default: true).