We use MUP to deploy our Meteor app, NYBR. MUP creates three docker containers for running the meteor app, nginx reverse proxy and mongo. Like most applications, the need for sending the email came, ideally we should be using Amazon Web Services SES, but getting their approval was a pain in the @$$ and was taking time. So, we did not want to hold back our development and decided to send the email through our own SMTP server until SES was approved.
We installed postfix and were hoping to get to developing and sending beautiful emails to our users. Unfortunately, we were greeted with the Connection refused error.
After trying various things in postfix configuration at,/etc/postfix/main.cf
turns out there is something called docker bridge (docker0) which acts a bridge between your ethernet port and Docker containers so that data can go back and forth.
So you have to listen on the docker0 interface. To do that, type ifconfig
on your host system to find out the bridge address and set your postfix to listen on it.
As you can see in the image above, the IP is 172.17.0.1
In postfix configuration located at /etc/postfix/main.cf
set
inet_interfaces = 172.17.0.1
While you are there, add your actual docker container ip address to mynetworks
mynetworks = 172.17.0.3 172.17.0.5
above two are private ip addresses of my docker containers from which I wish to send email.
You can find the IP address of your docker container by
docker inspect [container_id, container_name]
example
docker inspect my_container_name
Let me know in comments if you would like to learn how to send html emails in meteor.