Why Mail Engine

  1. Don't need to export and import your system data to any other mail systems(like mailchimp, mad_mimi).
  2. Allow user to edit all email templates directly in system admin, save the time of developer to participate in.
  3. Allow user to add mail sending schedule directly in system admin, don't need developer to add them into code or deploy crontab at server each time when client have new request.
  4. Fully take advantage of the convenience of loading any system data to mail template. In the past, like using mailchimp, you have to store everything into user list, then you are able to load that into mail template, it increased the complexity of maintaining information in another system.
  5. If you want to trace your mail, like open rate, click rate and unsubscribe rate, we provide Sendgrid integration configuration to take advantage that system. (More information at http://sendgrid.com)
  6. Allow logging all sent mails, you can check which mail been sent to which user.
  7. You can know send the email to the active users, so that you don't need to waste your credits of sendgrid or amazon.

Problem when using third party mail system

We are using mailchimp mostly for the newsletter solution, but it's has many problems that we have to make a new mail engine to fit our needs in real project:

  1. It is only one newsletter or marketing mail solution, so for system mail, it can do nothing, so for system mail we still go the original way (put them in the rails project.)
  2. Mailchimp don't support other encode for mail, when sending japanese or chinese mail it will be failed.
  3. It doesn't support localization, so different language is different campaign, you need to set a lot config for each of them.
  4. Manage user list is awkward, it even can't create list by API, so you have to create list one by one by hand.
  5. It can't load other user personal or customized data from system into mail, like latest unchecked news or messages, it's very limited to load info from user list record.
  6. It doesn't support reusable partials, which like you hope to put a fixed content of footer or header.
  7. It doesn't support recurring mail sending.

Installation

Step 1:

gem install mail_engine

Step 2:

Add management page needed javascript lib and css files, migration files and mailengineconfig.yml under config directory.

rails g mail_engine:install

Step 3:

Run migration.

rake db:migrate

Step 4:

Add below line to the crontab list of your sever:

### check mail schedule for every 15 minutes ###
*/4 * * * * sh -c "cd /path/to/your/system && rake mail_engine:sendmail RAILS_ENV=production"

Usage

For System Mail:

Due to the sender of system mail is ActionMailer, so you just need to set template physical store path (e.g. user_mailer/notify) as the mailer template load path, system will load it from database. (Notice, database template will override your file template.)

Mail Engine use Liquid template engine, so you can read the Liquid Reference at http://www.liquidmarkup.org/

Steps:

  1. Create a template in mail engine.

For Marketing Mail:

For normal marketing mails are quite simple in logic, so don't need logic code in the mail template. So we provide a mail dispatcher which allows user can send marketing mail only by providing the template and select the data pre-defined in system to the mail template, don't need developer to do anything like adding mailer file.

Steps:

  1. Create a mail tempate in mail engine.
  2. Create a sending schedule record. (You can specify the users to receive this mail, total sending count, sending period, when start to deliver the first mail and load which data into this template, You also can set condition for the scheduler, like if no specified data in collection, don't send the mail.)

You also can send mail in your program by using: MailEngine::MailDispatcher.marketing mail template name(:to => "Michael he hlxwell@gmail.com", :values => => "Michael He").deliver

Screenshots

Dashboard

Shows the latest report.

Dashboard

Template Management

You can manage the template used in your system, including:

  1. System mail, has it's own action mailer file.
  2. Marketing mail, simple logic and without it's own action mailer.
  3. Partials, you can reused it in any other templates.

Template Management

Template editing Page

You can see here are many details you can change:

  1. Template Path, system action mailer can find it when lookup mail template.
  2. Locale
  3. Format
  4. Layout
  5. Files will used in the template.
  6. Zip File when you used at creating this template.
  7. Preview template in time.

Template editing Preview

Upload html template with image in a zip file

You can create a template by uplaoding a zip file including one html and other images or css files.

Upload html template with image in a zip file.")

Partial and Layout selection

Partial and Layout selection

Mail Schedule

You can set a mail sending schedule, here are some useful setting items:

  1. Marketing Mail Template.
  2. User Group will be received this mail.
  3. Total send count.
  4. Already send count.
  5. Sending Period.
  6. Payloads which load from user model and send to template when sending.
  7. First send date time, this date will indicate when this mail will be send first time, and according to the seding period it will resend at the same time after one period.
  8. You can set requirements, which been predefined in the system, let the mail not been sent if the requirements is unreached.

Mail Schedule

Mail Logs

It will log all mails' content been sent, you can turn it off in config file.

Mail Logs

Report

Shows detail chart and data list of mail sending stats.

Report

Bounce Report

Bounce Report