The project is in a healthy, maintained state
Provides S3-based storage for letter_opener_web, enabling multi-instance deployments on Heroku, containers, and other platforms.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 3.0
~> 1.0

Runtime

 Project Readme

LetterOpenerWeb::S3

Amazon S3 storage backend for letter_opener_web.

This gem allows you to store email letters and attachments on Amazon S3 instead of the local filesystem, enabling multi-instance deployments on platforms like Heroku, Kubernetes, or any containerized environment.

Installation

Add this line to your application's Gemfile:

gem 'letter_opener_web'
gem 'letter_opener_web-s3', require: 'letter_opener_web_s3'

And then execute:

bundle install

Configuration

1. Configure AWS Credentials

Set up your AWS credentials and S3 bucket in your Rails configuration file (e.g., config/environments/development.rb):

# Require the gem first
require 'letter_opener_web_s3'

LetterOpenerWeb.configure do |config|
  # Use the S3 storage backend
  config.letter_class = LetterOpenerWeb::S3Letter

  # AWS Configuration
  config.aws_access_key_id = ENV['AWS_ACCESS_KEY_ID']
  config.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
  config.aws_region = 'us-east-1'
  config.aws_bucket = 'my-app-development-emails'
  config.aws_bucket_prefix = 'letters'  # Optional, defaults to 'letters'
end

2. Configure ActionMailer

Update your ActionMailer configuration to use the S3 delivery method:

config.action_mailer.delivery_method = :letter_opener_web_s3

Storage Structure

Emails are stored in S3 with the following structure (using default prefix letters):

YOUR-BUCKET-NAME/
└── letters/                    # Configurable via aws_bucket_prefix
    ├── {timestamp_id_1}/
    │   ├── plain.html
    │   ├── rich.html
    │   └── attachments/
    │       ├── file1.pdf
    │       └── file2.jpg
    └── {timestamp_id_2}/
        └── ...

You can customize the prefix by setting config.aws_bucket_prefix to organize emails under different paths in your bucket.

License

The gem is available as open source under the terms of the MIT License.