A docker container wasn't sending mail. I'd debugged the connection from the host machine and that was working, but once inside the container, there were no tools available. No mail, no mutt, no traceroute, no ping, no mtr, no netcat … so how to find out if the container could send to the mail server …
Well it turns out curl was available and curl can help! This command was able to send a test email without any of the tools I'd normally use on a full OS. Sweet.
curl --url 'smtp://103.125.202.12:25' \
--mail-from [email protected] \
--mail-rcpt [email protected] \
--upload-file - <<EOF
From: Mr Roboto <[email protected]>
To: Mailtest <[email protected]>
Subject: Robot Mail Test
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
So is it working? Maybe.
EOF
Other useful looking options, not needed this time were:
–ssl-reqd \
–user 'username:password' \
I did find another even more rudimentary connectivity check, which I'll put here for kicks, which doesn't even need curl.
(echo >/dev/tcp/103.125.202.12/25) &>/dev/null && echo "open" || echo "closed"
Its all about using what you've got. But then again if it wasn't for docker in the first place it would all have been a lot simpler …