The background
I'll tell you the background story first for the context. to make me in the future understand why I'm doing this in case I have forgotten about it :P
Recently, I found myself with some free time and feeling a bit bored. In the meantime while I was cleaning my room, I found an old notebook that had never been used for a long time; even so, it is still usable, and I have already installed arch linux on it previously. and I intend to run it 24/7 and make it as a home-lab, low-end, potato mini server. But I have no idea what it will be used for. Back then I was thinking about mining a cryptocurrency, so I asked for advice on some random github issue, but after giving it a second thought, it was the most amusing and ridiculous idea that I've ever had. and instead, I use it for my experiment and learning purposes.
In fact, this site, right now, is running on my potato notebook. Thanks to my friend Miru, who shows me this awesome blog template :)
The motivation
I bought a top-level domain and starting to learn how DNS works under the hood. and I want to extend its functionality not just as name resolution but also provide mail service from the domain. It seems forwarding any incoming messages from my domain (say, contact@reyuki.site
) to my gmail would be sufficient, but I think it would be interesting to setup an SMTP server to be able to send an email on behalf of me@reyuki.site
:3
Forward or relay any incoming emails
Let's get started by making any incoming emails to be forwarded to your primary email, I follow the guide cloudflare provide on this article, it's also possible to setup your own self-hosted email forwarder or relay and ditch Cloudflare email routing service from your sight, but maybe we can do it next time because right now my knowledge is limited to setup such thing.
You can follow the instruction from the article since the article already explain everything you need to know, and if you encounter any struggle, fix your own problem with search engine. Trust me, it's your best friend :P
After everything configured properly, you can test it! the following image shows the email message successfuly relayed to my primary gmail account:
The screenshot is taken from the Thunderbird client
Send an email message
We are missing some functionality, the abilitity to send an email message to the outbound on behalf me@reyuki.site
, unfortunately cloudflare email routing service didn't work in bi-directional way. So it doesn't provide support to do the opposite.
We need to be independent, and instead of relying on cloudflare service, we can self-host our own SMTP server to provide such service, but the problem is, my home lab server is only connected to the Internet through a cloudflare tunnel (I don't have a public IP, my ISP not allow me to port-forward). and cloudflare tunnel, as far as I know, didn't support or provide a way to expose your SMTP connection to the internet, so I will suspend this work and focus on other stuff...
please don't hesitate to leave a comment if you know some hacky ways to achieve this! I will very appreciate feedback!
Workaround
Right now, I use Brevo, it provide SMTP server and you can attach your domain name to it, further information available on my telegram channel.