Public | Automated Build

Last pushed: a year ago
Short Description
Short description is empty for this repo.
Full Description

##Testing mail server in a box.

The idea of this system is to help test the development of transactional emails and not be concerned about any email scripts you might use while developing. When testing emails sending out to actual email accounts is a bad idea. You want your code to be solid before thousands of emails are sent, this system will provide a solution so emails are not sent to actual mailboxes. If you are looking for a functional IMAP server visit this branch

Quick Tips

  1. Only emails or domains you grant access to will relay, this will allow you to point a domain to the final destination mail server. mailbase/domains
  2. The mail-loopback-base will contain all the default configuration files and any updates should be added to this container.
  3. Authentication creditials are stored in mailbase/sasl_passwd

Two build processes exist, use either fig or make to create an IMAP server with any important data safely keep in a persistent container. Make sure you switch to the git branch loopback.

##Command Line
CoreOS does not include make so you will need to open the Makefile and peice a few things together. This is one area I would love to see improved. Maybe build some fleetctl service files?

    $ git clone git@github.com:htmlgraphic/Mail-Server.git && cd Mail-Server
    $ git checkout loopback
    $ make data
    $ make build
    $ make run
    $ make start

##Using Fig

    $ git clone git@github.com:htmlgraphic/dockermail.git && cd dockermail
    $ git checkout loopback
    $ fig up -d
  • dovecot: SMTP and IMAP server. This container uses postfix / sasl as MTA and dovecot as IMAP server. All incoming mail to your own domains is accepted. For outgoing mail, only authenticated (logged in with username and password) clients can send messages via STARTTLS on port 587. Most programming langauges have a email library which can be used to connect securely for delivery. Within your application you can specifiy this docker instance hosted online. IE: test-smtp.domain.tld 587 using (TLS)

  • mail-loopback-base: This image is used to create the needed scripts which will live on the data container. This will allow you to share configuration files between multiple docker images.

Setup

###1) Allow email addresses

Any domains you want to receive mail should be listed mailbase/domains:

htmlgraphic.com     smtp:[imap-test.htmlgraphic.com]:587
otherdomain.com     smtp:[imap-test.htmlgraphic.com]:587

Any domains listed with the transport file will be sent out of the system and to the smtp host you specify. ALL other emails sent to this instance will bounce around and be removed from the queue every 12 hours. If you edit the transport file you will need to run postmap /etc/postfix/transport and reload postfix

###2) Add user aliases

Edit the file mailbase/aliases, to add any needed aliases:

root  hosting@domain.tld
johndoe@example.org         john.doe@example.org
john.doe@example.org        john.doe@example.org
admin@forum.example.org     forum-admin@example.org
@example.net          catch-all@example.net

An IMAP mail account is created for each entry on the right hand side.
Every mail sent to one of the addresses in the left column will
be delivered to the corresponding account in the right column.

###3) Add, review incoming username / password

Edit the file mailbase/passwords with the following:

john.doe@example.org:{PLAIN}password123
admin@example.org:{SHA256-CRYPT}$5$ojXGqoxOAygN91er$VQD/8dDyCYOaLl2yLJlRFXgl.NSrB3seZGXBRMdZAr6

To get the password hash values, you can connect to a running instance, if you are using Docker 1.3 and above.

###4) Add, review outgoing username / passwords

Edit the file mailbase/sasl_passwd with the following:

[imap-test.htmlgraphic.com]:587     testing@htmlgraphic.com:verysecurepassword

If you edit the sasl_passwd file you will need to run postmap /etc/postfix/sasl_passwd and reload postfix

Login to a running container, needs Docker 1.3 or greater. Optional, run the following after connecting to the running container:

$ docker exec -it <container.id> /bin/bash
$ doveadm pw -s <scheme-name>

Need to update the system configuration files, make changes to any the files found with /mailbase directory. Then, rebuild the dovecot container for the updates to take effect.

$ make stop
$ make remove
$ make build

Everything should be up and working, you should now be authenicating to send email but only the domain you set will delivery the email to logit mailboes . To check the running system run the following

$ docker logs <container.id>

Enjoy!

Docker Pull Command
Owner
htmlgraphic
Source Repository

Comments (0)