Hosting your own Mail servers is a great learning experience but it means dedicating a lot of time to ensure high availability and security standards.
Once you go beyond basic web hosting and your apps require more accuracy and horsepower you tend to switch to a VPS.
The more Experience you get in the Linux world the more you feel that A VPS gives you all the flexibility and power you need. Especially since you can now get them very cheap. For only $5 a month you can own your own 1GB RAM, 20GB SSD VPS. There are many shared hosting providers who sell at this price so a VPS is a logical choice.
So you might configure everything from scratch (like I did). Or you
could pay someone to do this. There is also the option to buy a managed
VPS, but you’d pay $100 or more per month and I think that a specialized
DevOps provides better support than managed VPS’es.
I’ve been managing my own VPS’es since 2009. Having invested
considerable effort into managing them I found that setting up and
managing your own mail servers is the most cumbersome task of all Linux
management.
If at this point you’re still not sure if a VPS is the ultimate solution I recommend you check out my post onhttp://andreiclinciu.net/blog/cloud-hosting-vps-shared-or-at-home-website-application-hosting-guide-for-aspiring-developers-and-small-business-owners[ Cloud Hosting, VPS, Shared, or At home Website Application Hosting Guide for aspiring Developers and Small Business Owners ]
A little introduction
The e-mail look-alikes have been around since the 1960’s.
Standardization came around 1973 with RFC 561 which is simply put a
paper describing "Standardizing Network Mail Headers".
If you’d compare how e-mail works with for example a client=server chat
application then the later will truly win in terms of simplicity of
implementation.
Setting up IMAP/POP3/SMTP with SSL etc and making sure they work
correctly across all domains is not a simple task.
if you take into account setting up spamassasin and clamav to scan for
spam and viruses you get your hands full for some days.
Ok, if you have 1 VPS you do this once and then don’t have to do
anything for 1 year. But if you CONSTANTLY deploy VPS’es you find
yourself in a trap.
No ansible, no chef and no puppet can help you with this one since you’d
break the whole system and most servers require different settings.
The best option I’ve found when combining DevOps speed vs cost is using
Webmin and Virtualmin.
Sure, they can setup even your Postfix,Dovecot IMAP,SMTP,POP mail
servers for you! Even with the click click mentality you still have a
lot of setup to do if you want everything to work correctly.
But then comes the real question. Do I really need to HOST my own mail
servers? Do I really need to have Dovecot, Postfix, Clam AV and Spam
Assasin eat my RAM and CPU?
Each process that has an open port to the outer world is a security risk
that needs to be tended and it increases the TCO (total cost of
ownership) considerably.
Do you really need to host your own mail servers?
Nope, you don’t. I’ll give you some examples, problems and solutions so you can decide for yourself what you truly need.
Admin panel
Cpanel automates most tasks and having it on your VPS is a great win.
But is +$20/month really worth it for most projects when it costs more
or equal to the vps itself?
Admin Panels automate many repetitive mail tasks, but do you really need
an expensive one?
For
only $20/month you can get a pretty neat VPS with 4 GB ram, 2 CPU cores,
48 GB ssd.. Pretty nice offer all for the price of CPANEL, right?
CPANEL has it’s benefits if you don’t mind paying the extra price,
however, if you’re serious about administering your VPS it’s better to
go to the command line most of the time
Sure if you have a VPS or dedicated that costs $100 per month then the price is not so big anymore.
Webmail setup
You’ll need to setup a webmail infrastructure. Cpanel and Webmin have these sorted out for you. But if you prefer to go the solo mode, you still need to install Roundcube or something similair. If you don’t use PHP then this means setting up nginx + php, thus extra hassle.
Administration Overhead
SSL management
You will need to manage your SSL certificates all alone for your
incoming and outgoing mail servers. This isn’t such a big problem but if
you deployed a VPS then you have the extra maintainence once a year when
you renew them.
You can chose to go with self signed certificates but your users will
always need to acknowledge this when using Outlook or Thunderbird.
Security
Although most people think of the mail system as 1 single software
server you have many interdependent working systems.
IMAP,POP3, SMTP all need Postfix, Dovecot, Spam Assasin, Clam AV and
other subcomponents!
Everyone wants to be safe. This means that you need to direct a lot of
attention and resources to ANTI SPAM and ANTI MALWARE software so you
and your users are safe.
Not to mention if you do have your own mail server you will need to
tweak everything all the time and be sure to have the most recent
updates.
High(er) resource usage
Protecting your users form viruses and spam means eating up more resources by installling antivirus and anti spam systems. The higher the security the more resources you end up using.
Spam and e-mail delivery
One issue is that when you run your own mail servers you usually get an IP that might have been used by someone else in the past. You have what IP it might be untill you have bought your VPS/hosting. If that IP has been blocked by some spam providers or it has been back/gray listed then you can consider yourself very unhappy,
I haven’t mentioned setting up DKIM and SPF which also take time. You will certainly need to have extreme care with those settings since you don’t want to get your e-mails bounced as spam!
A client of mine had bought a whole datacenter rack to host his own services at home. This required him to do a big investment. He bought 255 IP’s so he could use them. I’ve setup everything for him so that he could have various virtual machines for various services. One problem that persisted was that that IP address didn’t go through to certain e-mail providers like yahoo which just put the mails in spam. Gmail let them through as long as the mails did not contain images or anything else. Investigating this took a long time and it came out that there was a problem with various providers. They had "safe" ip’s which they allowed and all the rest where just blocked and considered spam. This means that if you have an IP outside of a known and trusted range from a serious Web Hosting company then expect to have bad luck.
While providing consulting services I’ve had various customer complain
about this issue with Gmail, Hotmail, Yahoo. It takes a lot of work to
get your mails not delivered as spam.
I even encourage my clients to stop using the mail() PHP function and to
use SMTP instead. THis increases the likelyhood of an e-mail being
delivered.
Recurrent installation
Setting up a fully working mail server every VPS is a big pain.
But at what cost?
The cost is that each VPS mailserver needs to be setup again. Even when using Virtualmin setting up a simple e-mail address in Outlook and Thunderbird becomes a big problem after adding a new subdomain with a new domain.
It’s usually not "usable" from the standpoint of using your users. Say the servers get upgraded and you decide to reinstall and migrate everything, this is where the fun starts.
For example, this blog had been running on a shared hosting for a long time. This might seem counterintuitive since all other projects I release for myself or clients run on their own VPS. At the time I didn’t want to have the hassle of handling ANY issues with my personal website. Since I need 100% mail uptime. In the meantime i’ve found the perfect solution.
However running your own VPS has a downside.. Maintenance. Hosting e-mail servers is NO exception because you need to maintain multiple services:
Postfix
Dovecot
clamav
SpamAssasin
Sure you could skip on the last two, but then again, why skip virus
checking and spam checking ?
Not a very good idea, even if you’re using Linux 100% of the time like
me.
Say everything is setup automatically.. and is working as expected, things can and will go wrong when you least expect it. This is the way it works when you try to manage everything yourself.
Uptime issue
Add to this the idea that it’s usually a bad idea to mix e-mail and hosting on the same VPS/Server. say your hosting provider goes down or your VPS is hit by something. Ok, no problem if you get a few hours of downtime. But what happens to all your e-mails during this time period?
Possible Solutions
Setting up ONE VPS to handle all mail from all other VPS apps
I’ve pondered and implemented this solution back in 2015-2016. The idea
is to have ONE specialized VPS that handles ALL e-mails for ALL clients
and domains I manage.
After some fidgeting around with an implementation I abandoned the idea
after one year.
Why have a single point of failure? Sure, I can setup 2=3 VPS’es that
handle everything and have a complete failover. But this takes a lot of
time and strain out of
You could externalize your whole mail system to third party business email providers
Yeah, with Office 365 and the Google suite for business you can certainly externalize everything, This way you have a big win whenever there’s a problem with your server/hosting you will be sure it doesn’t affect your own website.
Gsuite (Google)
Starting from $5 up to $25 per user per month.
This may seem like a good idea if you only have 1 mailbox and nothing
else. If you have multiple mailboxes and need forwarding and want to
have multiple domain names then this is not the option. At 10 mailboxes
you pay more in one month than the specialized offer at the end of this
article in one year!
Office 365
This one is hosted by Microsoft. It can go only for e-mail starting from
$8 per user per month. Or you can get a full
office/webhosting/conferencing suite from $15 per user per month.
Even from the standpoint of a small business I’d rather go with other
options
Other Options
There are other options around like Zoho and mail.com. They have the same price/options ratio which makes it a downside if you need multiple e-mail addresses.
I’ve done some market analysis and found out that whichever option you
chose figure out that it will cost you around $5 per month per user.
Yeah, you can use multiple aliases to get all mail in one big inbox but
still not a very good option in my opinion. Now, before we go further
please understand that I’m talking about $5 per month per user for a
mailbox environment like the one Gmail, yahoo or Hotmail offers. There
are certainly OPTIONS out there to send mails far cheaper than that.
Buy a shared hosting and duplicate your nameservers
One good option is to buy a shared hosting which you will
exclusively use ONLY for email.
You will add all your domains here, then you will point only your
mail.yourdomain.com to this service via DNS
Then you can migrate your DNS to the other hosting.
I need to state that this option is best for receiving e-mails and
sending them via your web inbox.
Mass sendnig should still be done via the working hosting/VPS or via
specialized e-mail marketing lists.
I’ve found this to be the easiest way to work with multiple severs. Making email always available, even in the event of crashes
The best option use specialized MX host (PREFFERED OPTION!)
This one is actually something between the shared hosting option and a
specialized 3d party app.
It’s unique in many ways. You only buy access to a mail box which has
something like CPANEL.
For example mxroute.com offers multiple plans.
For $30/year you get 5 GB of storage (MORE than enough), unlimited
domains and unlimited e-mail accounts.
If you compare this to the other offers where you pay $5 per user I say
you’ve got yourself the best deal the market has to offer.
Don’t forget, that you have unlimited domains and unlimited e-mail
accounts. This has to be the best option ever.
You can setup a mailbox which you will use to recieve and send e-mails
from your application via SMTP.
They have MailChannels integration for inbound and outbound mail which
means that you won’t get spammed and your e-mails will also reach the
other end without getting stuck in spam/junk.
But what If I need more space?
First ask yourself. DO you really need "unlimited" e-mail space? Do you really need 1GB or more?
Do you really need all those photo’s and documents stored as
attachements? Shouldn’t you use external hosting? Or even host your own
ownCloud for it?
In the beginning of the mail era, we had 3 MB. Then it expanded to 50,
100.. Then to 1 GB. 5 GB should be more than enough for 70.000 received
mails (calculated at an average 75KB mail including headers)
If yes then just upgrade your plan.. They also have 10-15-20-30-40GB
plans.
Whenever you exceed the 5GB just export the mail data and save it
locally (better to have a backup of your whole mail locally anyway!)
I’ve been using the same e-mail for business e-mails since 2012 and
switched to full personal/business usage since 2015. I also have setup
forwarding from other e-mail addresses and I’m currently at 228 MB. So
no, you probably don’t need more than 5 Gb.
Setup your own mail servers if security is the top priority
The only moment when I advise anyone to setup their own mail server is
if security is their top priority.
This means that you are 100% focused on securiing your VPS all the
time.
And you don’t want ANYONE else to have access even to your encrypted
e-mail.
All other cases, use a separate mail hosting service and use high encryption from within Thunderbird.
PSST. If you haven’t already moved from a shared hosting to your own VPS
please read my special guide on this topic
Cloud
Hosting, VPS, Shared, or At home Website Application Hosting Guide for
aspiring Developers and Small Business Owners
If you have already wanted to buy a VPS for some time but didn’t know if
you should do it then
Use the
follwing coupon with this link combination to recieve $10 on your
account! This means 2 months free for the basic VPS!
CODE: DOCS10
Conclusion(s)
Setting up a VPS with a fully working mailserver is something all DevOps should do once in their lifetime.
Try to use specialized e-mail providers
Separate mail from hosting at all costs!
I really recommend using MxRoute for your e-mails. They’re a small company dedicated to your mail needs.
Yes, your own VPS is better than a shared hosting. Having 2 different providers for mail and hosting is a MUST.