Giter VIP home page Giter VIP logo

mailassemble's Introduction

Email Assemble

Email Assemble is the 100% open source Single Page Application autoresponder application built in Rails 4.2 and Angular 1.4.

Setup

$ git clone [email protected]:heridev/MailAssemble.git
$ cd MailAssemble
$ bundle install
$ rake db:create
$ rake db:migrate
export DB_ADAPTER=postgress
export MANDRILL_API_KEY=HatU5GxeJFPo7zseDNozqr
export [email protected]
export USER_DELAYEDJOB=httpuserhere
export PASSWORD_DELAYEDJOB=mypass
$ rake jobs:work
$ rails server

Live Demo

http://emailassemble.herokuapp.com

Sorting: Postgress and mysql support

As you know there are a lot of tutorials about how to implement the sorting options in different frameworks, jquery, or plain javascript, but most of the tutorials includes for the backend code some lines as follow:

Specification.all.each do |spec|
  if position = params[:specifications].index(spec.id.to_s)
    spec.update_attribute(:position, position + 1) unless spec.position == position + 1
  end
end

Which is not performant enough of course, in order to tackle that performance problem when updating elements after sorting them I have added two special sql queries that either work for postgress and mysql and you can select which one you want to use using an environment variable, by default if you don't provide any value will make use of postgress query:

export DB_ADAPTER=mysql
# or
export DB_ADAPTER=postgress

Emails

For sending emails for the time being is using Mandrill so you need to generate your own credentials and export them before to run rails server

export MANDRILL_API_KEY=HatU5GxeJFPo7zseDNozqr
export [email protected]

MANDRILL

You must create a template within the mandrill templates section called "follow_ups": Mandrill template

The content for that template is pretty simple:

*|CONTENT|*

DELAYED JOBS

It is using Delayed job as a primary background worker, because in case you want to deploy the autoresponder into heroku you do not need to install any other piece of software and also you can run delayed jobs in heroku for free.

In order to run delayed jobs in development mode, you have to run the jobs work command in console after exporting the USER_DELAYEDJOB and PASSWORD_DELAYEDJOB variables:

export USER_DELAYEDJOB=httpuserhere
export PASSWORD_DELAYEDJOB=mypass
rake jobs:work

As the autoresponder is using delayed jobs web gem you can manage the jobs visiting the route /delayed_secret_job which is defined in the config/routes.rb in case you want to customize the url.

Running delayed jobs in heroku:

# in your Profile file:
worker: QUEUES=notifications bundle exec rake jobs:work

# if you want to add more just add them in that line something like:
worker: QUEUES=notifications,email,transactions,etc bundle exec rake jobs:work

Placeholder follow ups variables

In case you want to include the name or email in your follow ups you can do it using the placeholders for instance: Hello {{name}} Your email is {{email}}

Available variables at this time:

  • name
  • email

Scheduled follow ups

In order to send scheduled follow ups you can make use of:

bundle exec rake autoresponder:send_scheduled_follow_ups

So, for example you can create a cron job and invoke it each 10 minutes, if you're using heroku you can use scheduler.

NOTE: in case that you want to make sure that every follow up is sent correctly you can run this command each 30 minutes as well:

bundle exec rake autoresponder:send_oldest_follow_ups

TODO LIST

  • Support different email service provider for instance: MailGun, Sailthru, ZendGrid, etc.
  • Enable by configuration background worker implementations(rescue, sidekiq, etc) not only delayed jobs.

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.