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.
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.
$ git clone https://github.com/itp-world/email-bpe-elixir.git
$ cd email-bpe-elixir
$ mix deps.get
$ mix compile
$ mix run --no--halt (Stop with CTRL-C)
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.
$ iex -S mix run (Stop with CTRL-C)
iex([email protected])1> :observer.start()
A GUI will open with a lot of information about the running state of the app.
$ 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.
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
.
$ 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"
$ mix bpe.enqueue.job_poller_worker
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
$ mix bpe.reset
This will reset Redis / MongoDB and delete the ./tmp/
directory.