Rails Courrier
Rails-specific features for Courrier, the API-powered email delivery gem for Ruby.

Installation
Add to your Gemfile:
bundle add rails_courrier
Sponsored By Rails Designer
Setup
Generate the initializer:
bin/rails generate courrier:install
This creates config/initializers/courrier.rb.
Generate an email:
bin/rails generate courrier:email Order
This creates app/emails/order_email.rb.
Mount the engine for inbox previews:
# config/routes.rb
mount Courrier::Engine => "/courrier"
Usage
Send emails
OrderEmail.deliver to: "recipient@example.com"
Deliver later via ActiveJob
OrderEmail.deliver_later to: "recipient@example.com"
Configure queue options in the email class:
class OrderEmail < Courrier::Email
enqueue queue: "emails", wait: 5.minutes
def subject = "Your order is ready!"
# …
end
Inbox provider
Preview emails in your browser:
# config/initializers/courrier.rb
Courrier.configure do |config|
config.email = { provider: "inbox" }
end
Enable auto-open:
config.email = { provider: "inbox" }
config.inbox.auto_open = true
Clear inbox files:
bin/rails courrier:clear
URL helpers
Rails Courrier automatically includes Rails URL helpers in your email classes:
class OrderEmail < Courrier::Email
def text
"View your order: #{order_url(token: "abc123")}"
end
end
Documentation
See the Courrier README for full configuration, providers, layouts, templates and more.
Contributing
This project uses Standard for formatting Ruby code. Please make sure to run rake before submitting pull requests.
License
Courrier is released under the MIT License.