Saumit's webpage

Setting up an emailserver (CHALLENGE: EXTREMELY HARD)



Two or Three months ago I took the initiative of learning how to set up an email server on my VPS. After reading a lot on the topic I came to understand it is very vast and there is no one single thing that is at work here. So finally 2-3 weeks back (around 19 Oct) I tried to implement whatever I've learned and tried to create a simple mailserver.

However, I messed up real bad and eventually gave up. I made it on my og linux box with other services along with this site. Opened a bunch of ports with no recollection as I was referring to a bunch of resources at once but I had made so much mess that I couldn't clean up just by plain deleting and apt purging programs... Plus, I got quite frustrated after being up all night to work on this to then working at it again getting to my room after a full day of college. I swear I looked like a ghoul I was dead tired.

To which the only thing that looked good to me was to rsync the necessary files and reinstall the server. Fresh Start! I had fun doing the stuff again better and more minimal this time! Ansible has its place but I just love looking at my notes making changes to them and then following the newer instructions whenever I get to know a better method.
>Old habits.. they die hard.

With this blog I only mean to convey my experience (in a bland manner) and that I am no expert in this topic. If you wish to learn I would suggest referring to the Resources at the end :)


Firstly almost all email servers rely on Postfix and Dovecot!



One can also set up Lookup tables (databases) like MySQL/SQLite/PostgreSQL etc. but I much prefer to have my emails to maintain their primordial textual form :)

That's all there is to it in theory but then one thing became popular
SPAM and then it became quite so difficult to make a fully functioning secure mailserver that is Spamfree. I believe that's the reason you would need to raise a ticket to unblock your SMTP port if you're using a VPS for mail. Even if you notice any newsletter or some site that sends you mails regularly they have to mention at the end the option to "unsubscribe" from further emails. Will read more about it later.

During this attempt, I used a script by Luke Smith called emailwiz which automatizes(?) the entire process and it being Free and Open-Source several people have also contributed to the project (Even though it's just a shell script the amount of documentation is amazing) I improved upon and learned a few more things this time-

  1. Setting up Reverse DNS to my hostname
  2. Selectively learning and choosing which ports to keep for mail
  3. Checking and then Realizing many VPS providers block default SMTP ports and that you have to open a support ticket... (So it could be that I was doing just fine with my previous attempt though I am not sure)
  4. The script in addition also sets up Spam Assassin and OpenDKIM, which I spent time learning about.

There are various stages to setting up a fully secure email server and you can never be sure where you in particular messed up (unless you check the logs and can identify the problem).

My motive to make my mailserver was this image, which I got from an old friend who's a CompSci major (Shoutouts to Elijah) who's working at his dream company right now (unless he got laid off idk).


Wish to get more indepth into Email as a technology. Just a year ago I used to think of Gmail as the defacto email.
I remember my grandpa about email-address and then them asking me what is Gmail-address. I explained to them in a way they would understand like e-mail is "electronic mail" and said gmail is a type of email..there are a lot of other types of emails kind of like we have India Post and how in the USA they have USPS.
I explained to them in a way that didn't make them feel dumb and satisfied because It hurts to see that information gap between generations. So I made it easier to convey to them, my grandma worked in Typing department for Army and Grandpa worked in the Radio unit in the Army, he also knows Morse code! Really cool!! So I feel glad that I explained it to them which made better sense to them than some google search could ever do.

Drifting off the point, yeah what I wanted to say was even though they looked at me as if I know a whole lot about E-mail I didn't know anything. Now learning about Cloud Computing I am familiar with the distinction of IaaS (what I use as VPS),
Paas(What my roommate uses to deploy his react webdev projects on vercel)
and SaaS... which is what Gmail is!!!
There are so many layers to when you use Gmail.

And it's good(!?) SaaS is not that horrible if you think about it because no one has to go through all these hoops. Me trying to implement it on Base 1 (Base 0 being provisioning my hardware with port forwarding +wiping the disk clean and reinstalling the OS each time I fail lol) taught me alot.
The biggest thing it taught me was that there's yet more to learn :'(

So will be adding this new thing post each blog where I post my Future goals.

Email is such an old technology that still thrives and it's amazing to see. Funfact! SMTP existed even before HTTP. I remember reading Cal Newport's book 'Deep Work' and in some parts, his book entails "checking emails" as being this addictive non-productive yet some pseudo-productive thing?? I'm not sure But comparing that to modern times, Social Media is literally this on roids... Twitter fits this description so perfectly that in fact, my first tweet was.











Edit: SMTP port is now unblocked and I can send mails aswell.


Future Goals:

Resources I used:


Coolsites (brootally honest):

Further Reading/Talks (will read/watch if I plan to study indepth):