Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Email Delivery Engine in Elixir

This project provides an Elixir based background processing engine for email delivery. It uses Exq job processing library, Quantum cron-like job scheduler, Timex date/time library, Mailman mailer, UUID generator, Mongodb driver and HTTPotion HTTP client.

Requirements

Example for Ubuntu 12.04 or newer / Debian 7:

$ cd /tmp
$ wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
$ sudo dpkg -i erlang-solutions_1.0_all.deb
$ sudo apt-get update
$ sudo apt-get install erlang elixir redis-server

Follow the instructions on Install MongoDB Community Edition on Linux.

Installation

Get the sources:

$ git clone https://github.com/itp-world/email-bpe-elixir.git
$ cd email-bpe-elixir

Get dependencies and compile:

$ mix deps.get
$ mix compile

Startup

Job Processing:

$ mix run --no--halt (Stop with CTRL-C)

UI Dashboard:

Disabled in case of potential memory leak in Exq.Middleware.Stat currently!

$ mix exq.ui (Stop with CTRL-C)

Open http://localhost:4040 in your preferred browser.

Debugging:

$ iex -S mix run (Stop with CTRL-C)
iex(bpe@127.0.0.1)1> :observer.start()

A GUI will open with a lot of information about the running state of the app.

Erlang VM crash dumps:

$ erl -s crashdump_viewer

This starts the Crashdump Viewer GUI and loads the given file. If no file name is given, a file dialog will be opened where the file can be selected.

Email delivery service

To run the email delivery engine a template engine service is needed to create the HTML body of the EML files. For a quick start use the bpe-service-freemarker project. After its setup and start execute in different terminals the following commands:

  • Terminal #1 - Start Ratpack/Freemarker

    $ cd /path/to/bpe-service-freemarker
    $ gradle installApp
    $ ./build/install/service-freemarker/bin/service-freemarker
  • Terminal #2 - Start Background processing engine for email delivery

    $ cd /path/to/email-bpe-elixir
    $ mix run --no-halt
  • Terminal #3 - Create and enqueue a job

    $ cd /path/to/email-bpe-elixir
    $ mix bpe.jobs.create -j 1 -r 10000
    $ mix bpe.enqueue.job_poller_worker

The generated EML files are located under /path/to/email-bpe-elixir/tmp/smtp.

Jobs Generation

$ mix bpe.jobs.create
Usage: mix bpe.jobs.create <options>

  Options:
  --help       -h             this help
  --jobs       -j <Integer>   number of jobs
  --recipients -r <Integer>   number of recipients per job
  --sendat        <DateTime>  UTC date emails are sent to recipients, optional
                              e.g. 2016-02-05T14:59:38Z (ISO 8601)
  --nosendtime    <String>    optional UTC time interval during which no emails
                              are allowed to be sent, format "HH:MM HH:MM"

Enqueue Job Poller Worker

$ mix bpe.enqueue.job_poller_worker

(Un)Subscribe Exq Queues

You need to guarantee epmd (Erlang Port Mapper Daemon) is running on a port that is not blocked (you can run epmd -d for debug info) and you need to ensure all machines have a ~/.erlang.cookie file with exactly the same value.

$ mix bpe.client.queue_manager
Usage: mix bpe.client.queue_manager <options>

  Options:
  --help   -h            this help
  --node   -n <String>   node name of the BPE instance
  --queue  -q <String>   exq queue name to (un)subscribe
  --worker -w <Integer>  number of workers for subscription (optional)
  --(un)subscribe        (un)subscribes the queue

Reset BPE

$ mix bpe.reset

This will reset Redis / MongoDB and delete the ./tmp/ directory.

About

Email templating and delivery engine for high-throughput in Elixir

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages