CouchDB Plugin for Haraka
Caution: this is very beta
Here's how to set up your own SMTP server from scratch!
sudo apt-get install git-core)
node.js via these instructions. It is recommended that you build node yourself as opposed to using a package manager because it will make it easier to upgrade later. This app was developed against node version 0.4.8. You can install a specific version by running
git checkout v0.4.8 before running
npm, the node package manager:
curl http://npmjs.org/install.sh | sh
Download CouchBase server community edition. This is a prebuilt binary of CouchDB v1.0.2 with the GeoCouch plugin installed. There are other ways to install CouchDB on Ubuntu but they are a pain. Any Couch greater than v1.0 will work. To install:
# make the installation package executable chmod +x couchbase-server-community_x86_64_1.1.deb # install couch dpkg -i couchbase-server-community_x86_64_1.1.deb
By default CouchDB is not accessible to external network traffic, so you will have to be logged into the machine running Couch to interact with it. You can open up Couch to external traffic by setting the
0.0.0.0 in the Couch configuration:
curl -X PUT http://localhost:5984/_config/httpd/bind_address -d '"0.0.0.0"' -H "Content-type:application/json"
However, before you do this please be sure to read about the CouchDB security model.
npm install -g Haraka
The default Haraka configuration assumes you have a couch running at
http://localhost:5984 (this is also Couch's default). You can change this setting in the file
config/couchdb.url. Be sure to include your admin username and password in the URL if you have one set.
Also make sure to edit the file
config/me to contain the domain name that you want to receive mail at (the same domain as your MX record, or localhost for dev testing)
You can also set the database prefix name in the file
config/couchdb.dbPrefix. The default value is "mail_", which means that messages sent to
email@example.com will be stored in a database called
mail_bill in Couch.
git clone git://github.com/maxogden/haraka-couchdb.git cd haraka-couchdb npm install request npm install buffers sudo haraka -c .
Note: sudo is usually required to bind to port 25
You are now running a mail server! If you want to receive real mail using Haraka, you simply need to install this on a publicly accessible server and set your domain's MX DNS record to point at that server. For example, if you have an Amazon server with the address
http://ec2-1-2-3.compute-1.amazonaws.com and you own the domain name
pizzacats.com, just add two DNS records to
pizzacats.com: a CNAME record pointing at
ec2-1-2-3.compute-1.amazonaws.com and an MX record pointing at
Test it out
If you have an MX record set up correctly, just send an email to
firstname.lastname@example.org. A database called
mail_anyone will be created in your Couch and your message will be stored in it as JSON.
If you just want to test it locally, you can execute the included
test_send.rb ruby script to send a test email to yourself:
gem install mail mustache ruby test_send.rb
In your Couch you should now see a database called
mail_pizza (since the test messages are sent to a user called pizza) with some messages inside.