Giter Site home page Giter Site logo

postmortem's Introduction

PostMortem

PostMortem provides a simple and clean preview of all outgoing mails sent by your Ruby application to make email development a little less painful.

Every time your application sends an email a clearly-visible log entry will be written which provides a path to a temporary file containing your preview.

Take a look at a live example to see PostMortem in action.

PostMortem should only be enabled in test or development environments.

Features

  • Seamless integration with ActionMailer, Pony, Mail, etc.
  • Email deliveries are always intercepted (can be configured to pass through).
  • Live inbox monitors incoming emails so you can view them as soon as they are delivered.
  • Preview email content as well as typical email headers (recipients, subject, etc.).
  • View rendered HTML, plaintext, or HTML source with syntax highlighting (courtesy of highlight.js).
  • Content is loaded inside an <iframe> to ensure document isolation and validity.
  • Local images are located and embedded in HTML so you can see the full version of outgoing emails.
  • Runs without a server - single page app runs on file system with no need to run a local web server to access UI.
  • Any captured email can be downloaded into a standalone HTML file which can be shared with others.
  • Similarly, any captured eamil can also be uploaded to a stanadlone version of Postmortem at https://postmortem.delivery/

Installation

Add the gem to your application's Gemfile:

group :development, :test do
  gem 'postmortem', '~> 0.3.2'
end

And then execute:

$ bundle install

Or install it yourself as:

$ gem install postmortem

Usage

PostMortem automatically integrates with Rails ActionMailer and Pony. When an email is sent an entry will be visible in your application's log output.

If you are using assets (images etc.) with ActionMailer make sure to configure the asset host, e.g.:

# config/environments/development.rb
Rails.application.configure do
  config.action_mailer.asset_host = 'http://localhost:3000'
end

A log entry will be generated every time an email is sent. Load the path provided in the log entry in your browser to launch PostMortem:

Screenshot

Clearing the inbox

The inbox can be cleared at any time (e.g. at the start of a test run):

Postmortem.clear_inbox

Configuration

Configure PostMortem by calling Postmortem.configure, e.g. in a Rails initializer.

# config/initializers/postmortem.rb
Postmortem.configure do |config|
  # Colorize output in logs (path to preview HTML file) to improve visibility (default: true).
  config.colorize = true

  # Path to the PostMortem log file, where preview paths are written (default: STDOUT).
  config.log_path = '/path/to/postmortem.log'

  # Path to save preview .html files (default: OS-provided temp directory).
  # The directory will be created if it does not exist.
  config.preview_directory = '/path/to/postmortem/directory'

  # Provide a custom layout path if the default interface does not suit you.
  # See `layout/default.html.erb` for implementation reference.
  config.layout = '/path/to/layout'

  # Skip delivery of emails when using Pony, Mail, etc. (default: true).
  config.mail_skip_delivery = true
end

Contributing

Feel free to make a pull request.

License

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

postmortem's People

Contributors

bobf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

postmortem's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.