4000D / docker-mailtrap

Provides a simple catch all email server for development with smtp, imap and webmail support as docker image.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Purpose

Forked…​

This image provides a simple catch all email server for development with smtp, imap and webmail support. The base image is debian and only default packages are used. Only use this image for development purposes, because it is not designed to be secure. If it is connectable from the Internet, it can lead to an open relay mail server.

Inspired by

Performance & Improvements

This images uses dovecot as mda with sdbox as storage format, which delivers much more performance and stability than mbox with thousands of received mails. Also the image provides StartTLS / SSL with a selfsigned snakeoil certificate.

Available Services/Ports

  • SMTP Unsecure/StartTLS (25), SSL (465)

  • Submission Unsecure/StartTLS (587)

  • IMAP Unsecure/StartTLS (143), SSL (993)

  • HTTP (80) → Webmail Roundcube

  • /api/inbox → Inbox messages as simple json objects.

Environment variables with default values for customization

MAILTRAP_USER=mailtrap
MAILTRAP_PASSWORD=mailtrap
MAILTRAP_MAILBOX_LIMIT=51200000
MAILTRAP_MESSAGE_LIMIT=10240000
MAILTRAP_MAX_RECIPIENT_LIMIT=1000
MAILTRAP_ROUNDCUBE_CONFIG_REQUEST_PATH=""

Starting a container

Note: The examples use the flag --rm to automatically remove the container instance, when stopped. The flag --init is required to speed up the shutdown of the container. Also the ports are bound to localhost.

Simple container start

docker container run -d --rm --init --name=mailtrap -p 127.0.0.1:9080:80 -p 127.0.0.1:9025:25 dbck/mailtrap

All ports mapped

docker container run -d --rm --init --name=mailtrap -p 127.0.0.1:9080:80 -p 127.0.0.1:9025:25 -p 127.0.0.1:9587:587 -p 127.0.0.1:9465:465 -p 127.0.0.1:9143:143 -p 127.0.0.1:9993:993 dbck/mailtrap

Suggested port mapping

docker container run -d --rm --init --name=mailtrap -p 127.0.0.1:9080:80 -p 127.0.0.1:9025:25 -p 127.0.0.1:9587:587 -p 127.0.0.1:9143:143 dbck/mailtrap
docker logs -f mailtrap

Example docker-compose configuration

JSON API

The container provides a simple API under /api/inbox which returns a rudimentary view of messages received in the inbox. By calling /api/inbox?flush=true the received messages in the inbox will be flushed, after retrieval of the inbox as json.

[
    {
        "message_id": "<d083bf34a7a55e2049ae118feefc4b00@example.com>",
        "date": "Wed, 12 Jan 2021 20:14:55 +0100",
        "subject": "Hello from me",
        "from": [
            {
                "name": "Me",
                "address": "me@example.com"
            }
        ],
        "to": [
            {
                "name": "You",
                "address": "you@example.com"
            }
        ],
        "cc": [
            {
                "name": null,
                "address": "cc@example.com"
            }
        ],
        "reply_to": [
            {
                "name": null,
                "address": "reply-to@example.com"
            }
        ],
        "attachments": [
            {
                "filename": "Screenshot 2021-01-12 at 20.12.31.png"
            }
        ],
        "message": "   Hello You,\r\n\r\n   this is a test.\r\n\r\n   Cheers,\r\n   Me"
    }
]

Send test mail while container is running

docker-compose exec mailtrap /bin/bash
telnet mailtrap 25
ehlo example.com
mail from: me@example.com
rcpt to: you@example.com
data
Subject: Hello from me
Hello You,

This is a test.

Cheers,
Me
.
quit
exit

License

This software is licensed under the Apache License, Version 2.0 (the "License"); you may not use this files except in compliance with the License.

A copy is included in this repository in the LICENSE.txt file or you may obtain a copy of the License at here:

Unless required by applicable law or agreed to in writing, software and documentation distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Contributor covenant code of conduct

Please have a look in the CODE_OF_CONDUCT.adoc for information about Contributor covenant code of conduct.

Changelog

Changes will be tracked in CHANGELOG.adoc.

Contribution and development

Please take a look at CONTRIBUTING.adoc file for informations about contribution and development.

About

Provides a simple catch all email server for development with smtp, imap and webmail support as docker image.

License:Apache License 2.0


Languages

Language:PHP 57.1%Language:Shell 22.8%Language:Dockerfile 20.2%