The Test Portal server has been configured to use an SMTP host as per the documentation. The Portal server's IP has been added to the SMTP relay allow list. However, we are unable to send any emails.
API Portal 4.x
There was a conflict in subnet specification.
In this case the email server was in the range 10.0.1.X we found that the docker container could resolve the mail server name to the correct IP address, but that because docker was using the subnet 10.0.1.X it was not possible to route to the external 10.0.1.X mail server machine.
In setup of docker it is using internally three created networks -when we connect to the container trying to connect to the SMTP server :
docker exec -it <CONTAINER_ID> sh
Then run the route command :
Unfortunately, one of them is the 10.0.1.X network which blocks access to the external subnet 10.0.1.X - hence blocks access to the mail server. In the container, the DNS resolution works and we get the right IP for the mail server:
for i in `docker network ls | awk '{ print $1 }' `; do echo $i; (docker network inspect $i ); done
In this case, the SMTP server was set up on another subnet. Alternatively, it may be possible to change the subnet used for the API Portal docker as per :
https://techdocs.broadcom.com/us/en/ca-enterprise-software/layer7-api-management/api-developer-portal/4-5/install-configure-and-upgrade/install-portal-on-docker-swarm/troubleshoot-the-installation.html
This documents the setup of the 172.18.0.0 network, but may also be applicable to the 10.0.0.0 and 10.0.1.0 networks as well.
To find which image did the SMTP message, do the following:
While journalctl -f will give trace of all the logs (assuming /etc/docker/daemon.json is setup correctly), it will not identify which container the logs come from.
1. Find the ID of the container that is trying to make the SMTP call:
for i in `docker ps | awk '{ print $1 }' `; do echo $i; (docker logs $i 2>&1 | grep SMTP); done
Jul 19 05:34:28 examplecompany.example.com dockerd[27108]: WARNING: 4: Unable to send email: Unknown SMTP host: mail.example.com. Exception caught!
2. Connect to the identified container to print out the network and test resolving the SMTP host name:
docker exec -it <CONTAINER_ID> sh