16 ms·
Deploy a Gmail-like email server in 30 (ish) minutes
- focom 5y agoI think those projects: - https://mailinabox.email/ https://mailinabox.email/ - https://github.com/modoboa/modoboa https://github.com/modoboa/modoboa are better replacement. They are battery included with a webUI
- berkes 5y agoThere is also mailcow. I've been using mailinabox for years now, and it is really good in the sense that it gets out of my way. I've included it in my ansible setup, so the basis, distro, os updates, firewalls, backups are cositent with my other servers. That took some effort: mailinabox is opnionated (and that is good. It is the main reason it works well and is secure), which can be a bit confronting if your opninions are very different.
- geoah 5y ago> The blog article is the setup to make Docker Mailserver act like a Gmail server. I'm not sure what a Gmail server is. I was expecting this to include a web ui, admin ui, and the things that actually make Gmail hard to move away from. The docker-mailserver container doesn't seem to include something like that or am I just not seeing it? The killer feature for Gmail has always been the spam protection and the fact that the emails I sent actually get delivered.
- remram 5y agoDoes it have labels and full-text search, at least? edit: does the described setup include a UI at all?
- avian 5y agoIt's not the initial setup. It's the maintenance over the years that really makes you question the universe, life and the decision to host your own mail. When you can't send that important mail because $big_provider is blocking you. When someone decides to run a persistent brute force attack from a botnet, eating up 100% of your CPU and you have no meaningful ways to block it. When you need to explain to people why they can't send you that 100 MB video attachment which they sent to other people just fine but only your address is bouncing and why don't you fix your email already. When you need to research, understand and implement standard X pushed by $big_provider because otherwise things will stop working and you have a ton of better things to do. When you get a random alert that email volume is too large and you panic because someone hacked your server and is probably sending spam but realize it was just triggered by a huge kernel patch series sent by someone on a mailing list. When a zero-day CVE for your mail software just hit the top of the HN and the fix is not in your distro yet and you scramble to find a workaround. When a bunch of weird log lines appear in your mail logs and you don't understand where they are coming from and they seem benign but can't lose the feeling that someone is trying something malicious. When you constantly fear that you'll lose that good IP and domain reputation and one day wake up with half of the internet blocking you.
- emptybottle 5y agoThese concerns are common across virtually any internet facing service. Yes, if you choose to run a service it will need to be maintained, and occasional issues will come up.
- harikb 5y agoNo, email is an especially brutal service. I had taken this path for 10+ years. If my custom media server or private photo site setup fails, it is not a big deal. But if I can’t login to a shopping site or my family can’t checkin to a flight because the two-factor auth email disappeared in to thin air, I am the “horrible IT person” who spoiled Christmas - end of story.
- yokoprime 5y agoThis 100%, e-mail is too critical and is not core to what my skills are, so I outsource it, even if I think it would be fun setting up initially.
- everforward 5y agoWhat makes it particularly brutal, to me, is that the failures are typically silent. If GMail starts spamboxing my emails, I don't get feedback about that. If I'm not getting emails, I don't get feedback about that. You can script checking those, but you'll have to re-implement it for each provider. And there are some that you can't; if I'm applying for a job, they're not going to give me an email account to test whether my stuff is deliverable. HTTP services are absurdly easy to monitor in comparison.
- micromacrofoot 5y agoI’ve tried testing gmail and it’s very difficult to even get consistent results
- deleted 5y ago[deleted]
- tuldia 5y agoThe nicest email stack is: postfix, dovecot, rspamd and rainloop. EDIT: go check it out :-) https://www.rainloop.net/ https://www.rainloop.net/ EDIT 2: I don't understand why other comments are so agressive against the author for sharing how he runs his own mail server, I'm not sure if it comes from one's frustration, failures, unreasonable expectations about email, but I noticed that everything related to servers or email receives this hate (here on HN, eh?). Come on, let's start a new year where we appreciate someone sharing their experience in running a mail server :-) Happy Holidays!
- addicted 5y agoIf youre not on the cloud (and even there on AWS and maybe Google Cloud…Azure is ok in a pinch… and iCloud everything if you also overlap with the Mac crowd) are you even an engineer, seems to be one popular strain of HN thought, which comes out particularly aggressively against e-mail servers because they are arguably the worst type of server to run on your own.
- tuldia 5y agoYes, and doesn't makes sense, I don't know, I run my own email server for more than 10 years and my experience has been "setup and forget". I don't understand why so much frustration coming against owning your own stuff.
- kova12 5y agoI think it's because many of us here also did run our own email servers at some point in time, until realization came how hard it is to implement and support all features one gets instantly and effortlessly with gmail and such
- rahimnathwani 5y ago"I don't understand why other comments are so agressive against the author for sharing how he runs his own mail server" The author has been running his own mail server for less than half a week. There's no suggestion in the post that his setup is robust or 'Gmail-like', as claimed in the title.
- twobitshifter 5y agoIf you just want your own address, iCloud+ now supports custom domains. You might already be subscribed to it and not know it. This also includes private relay and email hiding. It might be the easiest way to move your email out of gmail. https://support.apple.com/guide/icloud/add-a-custom-domain-mma473945269/icloud https://support.apple.com/guide/icloud/add-a-custom-domain-m...
- albertgoeswoof 5y agoWhat would be the benefit of moving from one mega billion dollar company’s server to another?
- oskarc 5y agoImportant note - custom domains for iCloud is a very limited feature: - you can't send mails from more than 3 addresses per domain - it doesn't support catch-all Since I am in a time of moving to other city to study on university, I decided to abandon my mail server and migrate to iCloud... so now I am moving every of my service@domain.tld to prefix+service@domain.tld (tagging system that doesn't parse properly on some sites). It's no fun, but at least I'll take off my head caring whether my server is on fire, as it's now Apple's issue.
- throwaway984393 5y agoYou know, it's possible to build a house by yourself in about a day or two with no knowledge of carpentry. But I wouldn't want to live in it :)
- 15characterslon 5y ago> It was easier than I thought to create a mail server that works as well as Gmail’s No it isn't and no you didn't. The article doesn't even cover basic stuff like email rules and spam filtering (incl. tuning and spam learning). It doesn't "look after itself" like the author wanted (article doesn't mention any update strategy). The author acknowledges that email servers are "open to attack" but this setup doesn't seem to include any security improvements over traditional setups. In fact, maintaining this looks harder due to the amount of custom scripts and lack of good documentation. And of course it doesn't cover any of the things that actually make Gmail special like labels, having a consistent set of apps for web and mobile, push notifications (esp. on iOS), really good spam filtering, really good search (incl. OCR for attachments), high availability, image proxying, smart suggestions, datacenter security, Google doing code and infrastructure audits all the time, using reproducible builds, ... It's great that the author is experimenting and learning, but if I had any private data hosted by the author, I would be worried now.
- bluedino 5y agoGmails spam filtering isn't exactly a high bar
- rahimnathwani 5y agoBased on my experience running mail servers in the past (both personal and corporate), I'd say you're wrong.
- jjav 5y agoBased on my experience running mail servers for a long time and today, I'd say OP is right. gmail spam filtering is terrible. On my various gmail accounts, I both get spam and the good email goes to the spam folder. And there's nothing you can do, you can mark it not-spam a thousand times and it's still a crapshoot. I don't have any of those problems with my self-hosted email.
- entropie 5y agoI second this. Gmail spam filtering is top notch. I just stopped to care to obfuscate or hide my email adress (which I use since the beta invitation program of gmail) and I can count the spam I actually read in a year with one hand.
- deleted 5y ago[deleted]
- siraben 5y agoI recently got into running my own mail server on my NixOS instance using[0]. The server has a total of 1.5 GB RAM and 10 GB of disk space, but it was sufficient to get 10/10 on mail tester[1]. Here's my 12 line mailserver config[2]. It was quite liberating once everything was set up, because then you know you are in full control of your communications. It was more annoying to set up DNS than the mailserver itself, is there a good way to automate that as well? [0] https://gitlab.com/simple-nixos-mailserver/nixos-mailserver https://gitlab.com/simple-nixos-mailserver/nixos-mailserver [1] https://www.mail-tester.com/ https://www.mail-tester.com/ [2] https://github.com/siraben/dotfiles/blob/master/server/mailserver.nix https://github.com/siraben/dotfiles/blob/master/server/mails...
- lillecarl 5y agoTerraform has modules for many popular DNS providers. But that's another tool with its own state to maintain. I've used terraform for both Route53 and Cloudflare. siraben.dev doesn't seem to be registered anywhere so I don't know if there's one for your provider.
- siraben 5y agoIt’s registered via Google DNS. Looks like terraform can manage the records for it. Thanks!
- greggman3 5y agoAccording to many of the other posts here, running your own email server does not put you in"full control of your communications".
- siraben 5y agoThe reason that motivated me to run a mailserver is best described as an artisanal choice, not a practical one[0]. After all, I'm running this on a constrained system and certainly don't have ambitious to scale this to corporate scales. Like some other commentors here the point is mostly to learn and have something semi-useful at the same time (I've had some pleasant exchanges over my own email already.) [0] https://utcc.utoronto.ca/~cks/space/blog/sysadmin/EmailServersNoLongerPractical https://utcc.utoronto.ca/~cks/space/blog/sysadmin/EmailServe...
- pigbearpig 5y agoI'll be interested in the one month update post.
- imwillofficial 5y agoThis absolutely nothing like gmail. The great parts of gmail can’t be replicated at home anymore, unfortunately.
- freediver 5y ago> The great parts of gmail can’t be replicated at home anymore, unfortunately. Curious, what are those in your opinion?
- deleted 5y ago[deleted]
- imwillofficial 5y agoWell interface is an easy one. All the available guis for email work like steaming garbage. Another few are mail deliverability SSO, and security. Back in my day, deliverability wasn’t an issue, security wasn’t an ever looming specter, and feature parity was mostly there. I ended up throwing in the towel with Hey mail, and have really found love for email again.
- kevincox 5y agoPersonally I find the Gmail UI to be unusable for serious work. The threading is awful (based on subject instead of headers and collapses everything into a linear sequence) quickly going through an inbox is painful because the split view is incredibly basic and the way it tracks read-status in threads is far too unreliable to find what you need to see. Plus every time you open a long thread you need to scroll forever to get to the new messages. It makes me understand why most of my coworkers don't read their email.
- ohiovr 5y agoMail servers are all pretty much blacklisted by IP unless you work some kind of deal with someone somewhere.
- nulbyte 5y agoNot really. By definition, a blacklist is a list of things to block, and things not found on the list get a pass. Most use IP address or domain. Unless someone has reported something, they don't get added. The only real exception I can think of is "residential IP addresses, " as some blacklists will try to keep up with multiple ISPs' residential assignments to block them. Even then, they still have to he added to the list to block. Most have forms easily accessible to request review or unblock. Even Spamhaus has a very easy process, and I find them to be rather more aggressive then the others.
- eoo 5y agoAFAIK Digital Ocean blocks outbound connections to port 25. Has the author actually tried this setup? Source: https://docs.digitalocean.com/support/why-is-smtp-blocked/ https://docs.digitalocean.com/support/why-is-smtp-blocked/
- acallaghan 5y agoIt works perfectly yes. Maybe it’s not fully blocked, or DO restrict the amount of traffic over :25
- ireflect 5y agoI run a production email server on Digital Ocean and have not experienced this issue. An issue I have experienced is that one email provider (who provides a white label service so that small regional ISPs can include a free email account to their customers) has blocked anything coming from DO's IP block. Ultimately my solution is to route those emails (and only those emails) through mailgun.com. The other 99.9% of my outbound email gets delivered directly to the final email server with no issues.
- WarOnPrivacy 5y ago> one email provider has blocked anything coming from DO's IP block. Me. It is my consistent experience that traffic from DO's netblock rarely (actually never IRL) brings good tidings.
- tux2bsd 5y ago> Even on accounts where SMTP is available I don't know what those accounts are but you shouldn't make statements that are only partially true.
- johnklos 5y agoThis is nice, but even though I've administered email servers for a quarter of a century, I haven't got the foggiest clue what makes an email server "Gmail-like". What does "Gmail server" mean? I would think, if anything, that what Gmail has that typical email servers do not is somewhat decent webmail, but that can't be it because webmail isn't even mentioned. Or is this another one of those instances where people use "Linux" to refer to all things Unix? I genuinely would like to know.
- jahlove 5y agoSeems like a way for the author to get clicks.
- acallaghan 5y agoI was referring to Archive/All mail working, instead of just deleting all email, I should have been clearer I think - I don’t use the web UI so don't need a full replacement for that, even though it might be helpful
- jeroenhd 5y agoYou can't replicate Gmail, but with Mailcow I've gotta say the whole process is pretty seamless. You can throw it onto a 5 euro VPS at Contabo, run docker-compose up and be done. Just regularly run the update and backup scripts to make sure you're up to date but that's it, really. Exchange ActiveSync, multi domain + multi aliases with catchalls, (temporary) aliases, mail delivery rules, TLS requirements, you name it, all configurable in the web UI. There's even a built in DNS checking tool to verify that all the necessary records are set up right.
- mthld 5y agoI concur, a very well crafted and maintained project.
- acallaghan 5y agoI’ll take a look into this ta - the only thing really lacking in this setup is a UI for webmail or admin
- illuminated 5y agoI'm using mailcow for year and a half now, moved to it from Kolab. It's really great and painless to manage it. The only thing missing for me is the LDAP auth, something I got used to over the years with Kolab. The OP's solutions has built-in LDAP auth, so I'll give it a try.
- bsd44 5y agoI had to manage email infrastructure for years as part of my job and I really don't see how running your own email server can be a good idea for anyone. Setting it up superficially might be a quick and easy task but maintaining it stable takes hell of a lot of effort. I seriously cringe every time I see this type of guide and articles, it just makes me think that people who write them have zero experience running a mail server and have no idea what it takes to set up one that is secure and stable. For majority of people best middle ground is to buy a cheap domain and a cheap cPanel/web hosting and just use that to host emails. You'll be done in 5min, it will cost you a cup of coffee and you won't have the headache maintaining anything other than passwords.
- lgrapenthin 5y agoI'm using mailu.io with docker and haven't had any trouble for two years now. Cost me 1-2d in total.
- jjav 5y agoNo need for negativity. It takes very little effort to maintain a highly functioning self-hosted email infrastructure. I don't get these posts saying it's some impossible effort. Been doing it for a decade+, mostly not-doing since there's nothing to do, it just works perfectly.
- boplicity 5y agoYou can deploy an email server almost instantly by getting a cheap vps with cPanel on it -- with everything you needed already configured, including spam filtering, security, etc.
- maltris 5y agoFor docker and mail, also check out "mailcow dockerized". Lovely stack of software, been using it for 5 years with no problems.
- danlugo92 5y agoZoho has a 1 dollar a year plan for using with your own domain.
- commoner 5y agoZoho Mail has a free email hosting plan for up to 5 users (web and mobile/desktop app only, with no IMAP, POP, or ActiveSync access), but its paid plan (with IMAP, etc.) actually costs $1/user/month billed annually, which is $12/user/year. It's still less expensive than Google or Microsoft. https://www.zoho.com/mail/zohomail-pricing.html https://www.zoho.com/mail/zohomail-pricing.html
- lazyweb 5y agoIn my experience [1] running a small private mail server is very much doable, and a good learning experience. [1] https://jschumacher.info/2021/05/running-a-private-mail-server-for-six-years-easy-peasy/ https://jschumacher.info/2021/05/running-a-private-mail-serv...
- remram 5y agoWhat's a good way to monitor a self-hosted mail server? I can easily set up uptimerobot.com or similar and get alerted if my website fails, whether it's a DNS, IP, firewall, nginx, TLS^, application, or database issue. Is there a way to check my mail server and get alerted if it is not accepting emails for some reason? ^: uptimerobot.com specifically doesn't warn you if your site works but is using an expired certificate, be careful there
- jeffbee 5y agoI use and recommend the prometheus blackbox_exporter. You can configure a TCP connectivity check with TLS validation and an SMTP "expect" transcript. If you ran this in the cloud from multiple probing regions/clouds you'd have a monitoring scheme on par with what Google uses to monitor Gmail.
- systemsincode 5y agoGood article - seems comparing with Gmail upset some peeps but well done for having a go and trying to not just using off the shelf saas for every little things. Progress should have made it easier to host stuff ourselves not harder right?
- acallaghan 5y agoThanks! It works well for me, so people just are so negative - I didn’t really expect to upset their day so much… by ‘Gmail like’ I just meant Archive/All Mail working, not just deleting email
- augustuspolius 5y agoThis feature is not exclusive to gmail, I have it set up with all my email providers.
- acallaghan 5y agoIt wasn’t the default for docker-mail server & had to work out from the wiki how to configure it to work like this
- oliwarner 5y agoIt opens with some fair points why somebody might not, but the main reason —perhaps on par with the constant security headaches— isn't there. You will never block spam as effectively as Google, Microsoft, FastMail, etc. They see [for lack of a better word] infinite times more spam and ham than you'll ever be able to train your little Spam Assassin database, and millions of users to sort through it. Email without spam control is not a pleasant experience.
- acallaghan 5y agoThis is a valid point - The setup I used integrates SpamAssassin for the basic setup which would get a fair number. There’s a way to learn from listening to when you tag a message as spam that I didn’t cover in my article. But yeah, you’d never do as well as spam protection as the big companies, but is that really such a deal breaker? Maybe if more people like us ran their own infra for email then we’d have better and stronger tools for spam protection?
- jjav 5y ago> You will never block spam as effectively as Google, Microsoft, FastMail, etc. Well I certainly do, more effectively. I don't do anything special, it's just that gmail isn't that good. gmail gets a ton of false positives and to add insult to injury they also let spam through occasionally. My self-hosted infrastructure lets spam through at about the same rate as gmail, but my false-positive rate is orders of magnitude superior.
- Tepix 5y agoNow you have your own mail server. Great! But if you don't know how it works or if you don't have something that will help you maintain it, sooner or later it will break.
- acallaghan 5y agoIsn’t that the same with all things tech? Why try anything new at all without first getting a degree in it? I might get things wrong, so be it - I’ll use it to learn and be better next time.
- ireflect 5y agoSo many negative comments, sheesh. Many of us run our own small email servers quite successfully, even in 2021. Every time there's a post about it on HN, all these commenters come forward to say it's a fools errand, that it's nearly impossible, nobody should try it, anybody who says it's a good idea is a lying idiot, etc. Sure, it's not for everyone and there are pitfalls that require effort and sometimes creative solutions to overcome. We should celebrate these projects like we do with other similarly challenging projects that get posted.
- mysterydip 5y agoLet's say I'm tired of self-hosting my email (for all the reasons previously mentioned by others). What's a good option of privacy-conscious provider I can move my domains to?
- pandemicsoul 5y agoI think ProtonMail (https://protonmail.com/ https://protonmail.com/) is the only one that comes close to being "privacy conscious," mainly because it's their entire focus. Any other non-major, non-free provider might be an alternative but they're probably not as focused on being proactive about the privacy element?
- salzig 5y agoUhm, what about MailCow[0]? found it quite a while ago. Didn’t test it so far. [0]: https://mailcow.email/ https://mailcow.email/
- tuananh 5y agodefine gmail-like :)
- istillwritecode 5y agoincoming email is easy. Outgoing email is a whole different ball game. I tried setting up an SMTP server on digital ocean and found it to be impossible due to the fact that all Digital Ocean IP ranges are on various blacklists. I moved the server to AWS and was able to eventually get a running SMTP server, but it requires additional steps to gain the trust of AWS and outlook.com and other providers. It SHOULD be possible to set up an email server if you never never never never never send marketing email. If you DO send marketing email, then your stuff should be sent straight to the garbage bin and you should be on a blacklist. That's the whole point of spam.