How to get container X to send all mail via the postfix container
WillGibson opened this issue · 3 comments
@juanluisbaptiste We're nearing the end of "Dockerising" a legacy application.
The application uses Mailgun in itself to send emails, but we need to get the emails from any cron output (fatal errors etc.) sent out.
I am hoping we can do this with your docker-postfix image. I've got it running and sending email via Mailgun from itself, but have no idea how to configure the main application PHP container to route any emails cron would send via the postfix container.
Is this something you can advise on?
Our redacted Docker Compose file is as follows...
version: '2'
networks:
application-network:
volumes:
mysql:
driver: local
services:
mysql:
image: mysql:5.5.58
environment: &mysql_env
XXXXXXXXXX
restart: always
volumes:
- mysql:/var/lib/mysql
networks:
application-network:
aliases:
- XXXXXXXXXX
php-apache:
build:
context: ../
dockerfile: dockerfile/php-apache
image: XXXXXXXXXX-php-apache-5.6.32:v1.1.1
restart: always
environment:
<<: *mysql_env
volumes:
XXXXXXXXXX
ports:
- 33040:80
depends_on:
- mysql
- postfix
networks:
application-network:
postfix:
image: juanluisbaptiste/postfix:latest
expose:
- 25
environment:
SMTP_SERVER: smtp.mailgun.org
SMTP_USERNAME: postmaster@XXXXXXXXXX
SMTP_PASSWORD: XXXXXXXXXX
SERVER_HOSTNAME: XXXXXXXXXX
networks:
application-network:
Hi,
I think you just need to configure mailgun to use an external smtp server and configure the host to postfix, set port to 25, no user/password.
Thanks for the reply.
I'm confused, mail servers are not my thing to be honest, I have no experience setting them up.
Are you saying to configure our application container to use the host's Postfix instead of using juanluisbaptiste/docker-postfix?
Actually, we changed our approach and our deployment now creates the cron tasks on the host, running the command in the docker containers via Docker Compose, so now we don't need to faff around with postfix :-)