tl;dr

Orange is the new grey aka how to lose 2 hours on Cloudflare grey/orange settings!

The Cloudflare documentation is explicit, don't use the Orange cloud 🌥 for MX settings.
So TIL, as usual RTFM, but also something about the colors of the clouds!

rtfm

The errands

This afternoon I decided on a small API project I'm working on to use along with its usual docker-compose a mailserver service.

While using mailtrap.io or others comparable solutions is quick and useful most of the time, their free version is somewhat limited and I wanted the ability to mass email myself in developemnt.

For a solid mailserver, the docker-mailserver image is impressively well maintained, documented, easy to setup.

After I setup DKIM and SPF records in my TXT DNS settings, I wanted to test the emails sending with my favorite email library: emails

Here's a small snippet:

import emails

user = "user@domain.tld"
password = "devpass"
host = "smtp.domain.tld"
port = 587
mail_from = "user@domain.tld"
to = "randomuser@gmail.com"

smtp = {"fail_silently": False,
        "host": host,
        "port": port,
        "tls": True,
        "user": user,
        "password": password
        }

for i in range(10000):
    m = emails.Message(text=f"I'm message {i}", subject=f"Attention",
                       mail_from=mail_from)
    response = m.send(to=to, smtp=smtp)
    print(response)

The answer I was having was:

    raise self._exc
emails.backend.smtp.exceptions.SMTPConnectNetworkError: [Errno 101] Network is unreachable: None

the reason was that in my cloudflare dashboard, I forgot to remove the orange settings for the A record.

As usual stackoverflow was of great help.

Conclusion

RTFM, use nc while dealing with network issues.