Sign inSign up

boomfish/postfix-mailtrap

By boomfish

Updated over 11 years ago

Docker container to forward all incoming mails to a single mailbox

Image
0

551

boomfish/postfix-mailtrap repository overview

docker-postfix-mailtrap

run postfix in a Docker container to forward all incoming mails to a single mailbox on the Docker host. Intended for developers of applications that send email to arbitrary addresses.

Installation

  1. Pull image

    sudo docker pull boomfish/postfix-mailtrap
    

Usage

  1. Create and run a postfix container that maps its mail spool to the host's mail spool

    sudo docker run \
    		-e mynetworks="192.168.1.0/24" -e mailbox_username=alan -e mailbox_uid=1001 \
    		-v /var/mail:/var/mail --name mailtrap -d boomfish/postfix-mailtrap
    
  2. Create application containers that link to the mailtrap container for their outgoing SMTP service

    sudo docker run -l mailtrap:mailhost -d myapp
    
  3. When an application container sends email via mailhost, check for it in the specified mailbox (in this case alan) on the Docker host using your favourite mail reader.

Notes

  • The mailbox defaults to vagrant (uid 1000) which is what you usually want if you're running Docker under Vagrant.
  • Due to anti-relay protections postfix will reject unauthenticated emails from hosts that are not in any of "mynetworks" subnets, so you'll need to set "mynetworks" to the subnet range used by your Docker containers. The default for "mynetworks" includes all class B subnets (which is what Docker uses for local container interfaces).
  • If you wish to use SASL SMTP authentication read the information on docker-postfix.

License

This code is available under the MIT License.

Acknowledgements

This Docker image is built over the docker-postfix image by Elliot Ye. The install.sh script is based largely off the same script from that repository.

Tag summary

Content type

Image

Digest

sha256:d892b0e4a

Size

97.8 MB

Last updated

almost 11 years ago

docker pull boomfish/postfix-mailtrap