|
1 | | -## Development Mail Server |
| 1 | +# Development Mail Server |
2 | 2 |
|
3 | | -The purpose of this image to to emulate a Postfix/mail server but never actually send any mail out to the world. This is useful when developing web applications which are expected to send mail but you don't want them to accidentally mail real users or if you wish to inspect the mail that the application would normally send out. |
| 3 | +A Docker image that runs a complete mail server stack, perfect for development and testing. It's designed to be a catch-all server that receives emails for any address and displays them in a web interface. It **does not** send any mail out to the internet. |
4 | 4 |
|
5 | | -The image comes with Roundcube installed and running on port 80 which collects the outbound mail. Mail is cleaned up after 24 hours. |
| 5 | +This image includes: |
6 | 6 |
|
7 | | -## Authentication |
| 7 | +- Postfix as a mail transfer agent (MTA). |
| 8 | +- Dovecot for IMAP and POP3 access. |
| 9 | +- Apache with PHP to serve the webmail client. |
| 10 | +- Roundcube as a webmail client to view emails. |
| 11 | +- A cron job that cleans up emails older than 24 hours. |
8 | 12 |
|
9 | | -There is no authentication required for all services. |
| 13 | +## Features |
| 14 | + |
| 15 | +- Catch-all email server for any domain. |
| 16 | +- Web-based email access with Roundcube. |
| 17 | +- IMAP and POP3 access to emails. |
| 18 | +- Automatic cleanup of old emails. |
| 19 | +- Configurable via environment variables. |
| 20 | + |
| 21 | +## Getting Started |
| 22 | + |
| 23 | +This guide provides instructions on how to build and run the Docker image using either the provided `Makefile` or standard `docker` commands. |
| 24 | + |
| 25 | +### Using Makefile |
| 26 | + |
| 27 | +The `Makefile` provides convenience targets for common operations. |
| 28 | + |
| 29 | +1. **Build the image:** |
| 30 | + ```sh |
| 31 | + make build |
| 32 | + ``` |
| 33 | + |
| 34 | +2. **Run the container:** |
| 35 | + To run the container for development or testing, which exposes the web interface on port `8080`: |
| 36 | + ```sh |
| 37 | + make run |
| 38 | + ``` |
| 39 | + This command will attach to the container's output. You can detach with `Ctrl+C`. |
| 40 | +
|
| 41 | +## Accessing Emails |
| 42 | +
|
| 43 | +### Web Interface |
| 44 | +The captured emails are available through the Roundcube web interface. If you followed the "Getting Started" example, it will be available at [http://localhost:8080](http://localhost:8080). |
| 45 | +
|
| 46 | +The interface uses an autologin plugin, so no username or password is required. |
| 47 | +
|
| 48 | +### SMTP, IMAP & POP3 |
| 49 | +
|
| 50 | +To configure your application, use `localhost` (or your Docker host IP) as the server and the ports you exposed. |
| 51 | +
|
| 52 | +- **SMTP server**: `localhost` on port `1025` (no authentication required). |
| 53 | +- **IMAP server**: `localhost` on port `1143` (user: `catchall`). |
| 54 | +- **POP3 server**: `localhost` on port `1110` (user: `catchall`). |
| 55 | +
|
| 56 | +## Configuration |
| 57 | +
|
| 58 | +### Main Environment Variables |
| 59 | +
|
| 60 | +| Variable | Description | Default | |
| 61 | +|-------------|---------------------------------------------------------------------------------------------------------------|---------------------------| |
| 62 | +| `MAILNAME` | The mail domain for the server. This is used by Postfix in its configuration. | `maildev.example.com` | |
| 63 | +| `SIZELIMIT` | The maximum size of an email in bytes. | `20480000` (20MB) | |
| 64 | +| `POSTCONF` | A space-separated list of Postfix configuration directives. For example `disable_dns_lookups=yes`. | `(empty)` | |
| 65 | +
|
| 66 | +See [panubo/docker-postfix](https://github.com/panubo/docker-postfix?tab=readme-ov-file#environment-variables) for more configuration options. |
| 67 | +
|
| 68 | +### Volumes |
| 69 | +
|
| 70 | +| Path | Description | |
| 71 | +|--------------|-------------------------------------------------| |
| 72 | +| `/var/mail` | The directory where emails are stored. | |
| 73 | +
|
| 74 | +## Ports |
| 75 | +
|
| 76 | +| Port | Protocol | Description | |
| 77 | +|-------|----------|--------------------| |
| 78 | +| 25 | SMTP | Mail submission | |
| 79 | +| 80 | HTTP | Roundcube webmail | |
| 80 | +| 110 | POP3 | Email access | |
| 81 | +| 143 | IMAP | Email access | |
| 82 | +
|
| 83 | +## Development |
| 84 | +
|
| 85 | +The `Makefile` contains several targets for common development tasks. |
| 86 | +
|
| 87 | +- `make build`: Build the Docker image. |
| 88 | +- `make run`: Run the container for testing the web interface. |
| 89 | +- `make bash`: Get a bash shell inside a running container. |
| 90 | +- `make clean`: Remove the built image. |
| 91 | +
|
| 92 | +See the `Makefile` for more details and other available targets. |
| 93 | +
|
| 94 | +## Releases |
| 95 | +
|
| 96 | +Please use a versioned release rather than the floating 'latest' tag. |
| 97 | +
|
| 98 | +See the releases for tag usage and release notes. |
| 99 | +
|
| 100 | +## Status |
| 101 | +
|
| 102 | +Development ready and stable. |
0 commit comments