Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tyrauber/email_engine

Send and track emails at scale with Rails and Redis
https://github.com/tyrauber/email_engine

Last synced: 3 months ago
JSON representation

Send and track emails at scale with Rails and Redis

Awesome Lists containing this project

README

        

# EmailEngine

Send and track emails at scale with Rails and Redis

You get:

- A history of every email sent
- Track Sent, Open, Click, Unsubscribe, Success, Bounce and Complaint
- Easy UTM tagging

Works with any STMP provider but has built in Amazon SES callbacks (Success, Bounce and Complaint).

# Purpose

Send and track *hundreds of thousands of emails per hour*, with minimal resources.

# In Development. Subject to Change

## Installation

Add this line to your application’s Gemfile:

```ruby
gem 'email_engine'
```

Generate and modify the initializer:

```ruby
rails generate email_engine:install
```

## Routes

By default, EmailEngine will mount at root with /emails as the user facing resource and /admin/emails as the admin resource. You can change the route by manually mounting the engine.

```ruby
mount EmailEngine::Engine => "/messages", as: 'email_engine'
```

If you use RailsEngine, ActiveAdmin or any other /admin namespaced engine, you'll need to mount EmailEngine first, otherwise the other engine might override the EmailEngine admin routes.

## Authorization

EmailEngine is configured to leverage the CanCan Authorization gem and the existing ability file. The following ability example would grant basic access to all users and restrict access to the EmailEngine admin to only users where user.admin? is true.

```ruby
def initialize(user)
user ||= User.new
can [:open, :click, :unsubscribe, :bounce, :complaint], EmailEngine::Email
if user.admin?
can :manage, EmailEngine::Email
end
end
```

## How It Works

The tracking of email headers, content and statistics are all handled through Redis.

Every email has a unique Message Token, which is applied to the email header as "EMAIL-ENGINE-ID". Open, click and unsubscribe links use that Message Token to track usage, and stats are generated.

An admin provides the ability to monitor email performance.

### Users

EmailEngine tracks the user a message is sent to - not just the email address. This gives you a full history of messages for each user, even if he or she changes addresses.

By default, EmailEngine tries `User.where(email: message.to.first).first` to find the user.

You can pass a specific user with:

```ruby
class UserMailer < ActionMailer::Base
def welcome_email(user)
# ...
track user: user
mail to: user.email
end
end
```

### Opens

An invisible pixel is added right before the `