Live data from Hacker News

How to Run Your Own Mail Server (2017)

c0ffee.net

211–220 of 339 posts

Re: How to Run Your Own Mail Server (2017)

#211
post #43

Earlier quoted context omitted.

What do you mean with 'mail server'? Postfix? Dovecot? Running a Postfix on anything else than a dedicated server with a static IP is a pretty bad idea (half the internet will reject the emails you send). And to do all that just to transfer some files is probably like using an iPhone as a fly swatter.

I don't know why there's so many downvotes and patronising "fly swatter" remarks. There is a use case for this. For example, sharing a photo album with many pictures. Or a mixtape. Or some song lyrics. I can't upload those to the cloud for copyright reasons. Or if I want to make the transfer while away from Internet e.g. skiing, hiking, waterfall trip, etc. - there's no access to Internet services, so iCloud/Dropbox/…

> We could both install a special app for Bluetooth transfers, but we don't have Internet access, remember? So no app store.

Why not install the special Bluetooth app whenever you were planning to install the smtp server?

Re: How to Run Your Own Mail Server (2017)

#212
post #143

I run my own mail infrastructure. To say the least I wouldn't recommend it even to my worst enemies. It's horrible. Actually it's fine until it's not. Then your email doesn't work and you could be missing out on important communications. And then you're scrambling to figure out how the spammers managed to exploit your setup this time. And you have to learn a tonne of crap in order to manage it... and the text files!…

"And then you're scrambling to figure out how the spammers managed to exploit your setup this time." ... " ... writing a MTA with the goal of minimizing configuration and being secure and resistant to attacks by default. " As a 20+ year UNIX sysadmin and fellow owner of my own email infrastructure for 18 of those, I am surprised to read this and am not even sure what you are talking about. Can you explain what you me…

I'm in the same boat - been running my own mail since the 90s. I could understand complaints about lots of weird hoops to jump through to get mail from your server accepted elsewhere - that has become harder over time[1] - but there's a very short list of things that need to be done to avoid being hijacked.

Mail server setup for the uninitiated does look a little daunting, especially if you're more accustomed to "all-in-one"-ish software. If you want to do this, I recommend starting with making sure you have a clear mental model of mail server architecture, especially where it touches other things (DNS, DKIM, spam filters, local delivery, probably IMAP, maybe LDAP, maybe databases, etc.) Without a clear idea of the dataflow and reasons for different decision-points, you're going to have a very bad time troubleshooting things.

[1] SBCGlobal.net has been rejecting me for over a decade despite there being zero spam ever having been emitted by my domain. Eh, my userbase communicates with exactly one SBC user; ATT can bite me.

Re: How to Run Your Own Mail Server (2017)

#213
post #23

Icing on the cake: Sprinkle a little Let's Encrypt in there to cover SSL. It doesn't take much to have a cron make a new cert and restart dovecot and postfix. My setup is similar, but it uses MySQL instead of LDAP. I love being able to make aliases and even better - deleting them when I'm done with them.

Author here - I plan on switching to Let’s Encrypt once they support ECC certificates.

I think they do support ECC certificates: https://cromwell-intl.com/open-source/google-freebsd-tls/tls...

Re: How to Run Your Own Mail Server (2017)

#214
One thing I'd like to see covered is sender dependent outgoing mail routing.

For example, suppose I have things set up so all outgoing mail from my home goes through my SMTP server. If I send an email with a from address of tzs@mydomain, then the setup in the article is perfect.

Suppose, though, I send an email from home with my from address set to tzs@employer, where "employer" is my employer's domain? Assume this email is not to an @employer address [1]. With the setup in the article (and in almost every other similar setup I've seen covered in similar articles) this might run into spam filter issues unless I've convinced my employer to add my SMTP server to their SPF record.

The way I want this to be handled is for my SMTP server to see that the mail is from an @employer address, and instead of trying to deliver it directly, relay it through employer's SMTP server.

This is similar to the common "smart host" configuration often used when you run an SMTP server at home, but want it to send all outgoing mail through your ISP's SMTP server instead of trying direct delivery. Essentially what I want is a conditional smart host based on the from address.

Postfix supports this. In fact, it seems to support it in a couple different ways. I played with it a bit but could not quite get it working.

What I'm doing for now, until I find out how to do it right, is only send work email outside of work from my desktop Mac. I took tzs@employer off the list of mail aliases for my mydomain mail account, and created a second account in Apple Mail for @employer. I set the incoming mail server to POP3 on 127.0.0.1 so that it would fail, and set the outgoing server to smtp.employer. It complained for a while that it could not contact the POP3 server, but eventually stopped complaining, and the address in the configuration dialog changed to 0.0.0.0.

With that setup Apple Mail sends mail from @employer directly to my employer's SMTP.

Sometime recently, after an OS update, that stopped working. It would no longer let me enable an account unless it could successfully talk to the incoming mail server for that account.

I did find an ugly workaround for that. I gave it the correct address for employer's POP3 server, and the correct password. Once it was happy, I went to Keychain Access, found the saved password for the POP3 server, and changed it in Keychain Access to something incorrect. Mail then complains that it cannot login to the POP3 server, but that does not cause it to disable the account. Net effect: a send only account in Apple Mail. (It is important to do the password change in Keychain Access, not in Mail, because Mail won't save the change until it sees the new password work).

(If that had not worked, I probably would have written a dummy POP3 server that always reports no mail and used that).

[1] This happens reasonably often for me, because I have my mail server set up to use fetchmail to fetch my incoming work email and deliver it via procmail. Same for any other SMTP accounts I have. That way I only have to configure mail clients to work with mail server and I get access to all my mail from all of my non-web email accounts.

Re: How to Run Your Own Mail Server (2017)

#215

Earlier quoted context omitted.

I ran my own mail server (a few VMs in the cloud) for about five years. It's fun as you have control over accounts, aliases, forwarding, sieve tricks as well as backups. It's good to know that your broker and doctor's mail is delivered directly to your server and not Google. It sucks ass when your mail does not get through as GMail/Hotmail rejects a connection from the IP address your cloud company allocated for you,…

Actually one fun way of doing it is to run your own email setup using one of the big ESPs as a "proxy". You can do it for both inbound and outbound. You can have a domain registered with Gmail or Rackspace Mail or whatever, and use the SMTP credentials they give you for outbound, while keeping MX records point to your own SMTP for inbound. Or you can let them process the inbound as well (fighting spam for you) and yo…

But then they can already read everything you send and receive. At that point it's better to just use IMAP if you want to have all the e-mails local and backupped...

Re: How to Run Your Own Mail Server (2017)

#216
post #143

I run my own mail infrastructure. To say the least I wouldn't recommend it even to my worst enemies. It's horrible. Actually it's fine until it's not. Then your email doesn't work and you could be missing out on important communications. And then you're scrambling to figure out how the spammers managed to exploit your setup this time. And you have to learn a tonne of crap in order to manage it... and the text files!…

"And then you're scrambling to figure out how the spammers managed to exploit your setup this time." ... " ... writing a MTA with the goal of minimizing configuration and being secure and resistant to attacks by default. " As a 20+ year UNIX sysadmin and fellow owner of my own email infrastructure for 18 of those, I am surprised to read this and am not even sure what you are talking about. Can you explain what you me…

To be fair I've been running my infrastructure for years and it's usually fine.

The problem I have is that it's a pain in the ass to setup correctly and when things do go wrong it's really hard to figure out what's going on.

> Can you explain what you mean by attacks and exploits from spammers?

I haven't encountered a remote exploit (yet) but yes: accidentally running an open relay, backscattering, etc. You also have to worry about the system security of the box you're running it all on but let's treat that as a separate concern.

I'd been running my setup for years and as recently as August of last year I was dealing with an outage of my email server. I must've missed something somewhere because someone had figured it out and started using my server as a relay. It took me a few days to figure it out and I'm still not sure what the problem was or how I fixed it. Though my server stopped bouncing emails and started forwarding things again so... win?

As I was fixing this issue, not the first time, it occurred to me that it was just criminally easy to not know if your system is being exploited as a relay or not. There are a bunch of different configuration files in all different formats and guides that require working through dozens of steps. It's way too easy to get something wrong.

For someone like me who works at deploying software running on hundreds of nodes it seems manageable but I don't think it's ready for my cousin who's good with computers.

That's where the idea for a secure-by-default MTA that couldn't possibly be configured to be an open relay came from. Minimize the configuration so it was hard to get wrong even at the expense of flexibility.

I dunno, maybe it's not a great idea. But it's fun to hack on in the evenings when I've got nothing better to do and hopefully I'll have a fewer text files to manage in the future.

Re: How to Run Your Own Mail Server (2017)

#217

I run my own mail infrastructure. To say the least I wouldn't recommend it even to my worst enemies. It's horrible. Actually it's fine until it's not. Then your email doesn't work and you could be missing out on important communications. And then you're scrambling to figure out how the spammers managed to exploit your setup this time. And you have to learn a tonne of crap in order to manage it... and the text files!…

I ran my own mail server (a few VMs in the cloud) for about five years. It's fun as you have control over accounts, aliases, forwarding, sieve tricks as well as backups. It's good to know that your broker and doctor's mail is delivered directly to your server and not Google. It sucks ass when your mail does not get through as GMail/Hotmail rejects a connection from the IP address your cloud company allocated for you,…

> It sucks ass when your mail does not get through as GMail/Hotmail rejects a connection from the IP address your cloud company allocated for you, in spite of DKIM etc.

God, yes. Gmail, in particular, really enjoyed just dropping connections from my IPv6 addresses every few months. Sometimes it would return an error, something obtuse and wrong like maybe, "your forward and reverse DNS records do not match" even though they absolutely did and hadn't changed in years.

Outlook/Hotmail was far better and would always return a sane, yet sometimes inscrutable, error that bore some resemblance to reality. It still took them a week to get me off the hit list that I got dropped on for no discernible reason.

> Or they decide to mark your mail is "suspicious" and it goes into the recipient's Spam folder.

Gmail was the ABSOLUTE FUCKING WORST about this. My spouse's e-mail to Etsy customers who used Gmail--not spam, not newsletters, person-to-person e-mails INITIATED BY THE CUSTOMER--would work for the first couple of e-mails in a thread and then start going into spam. Or, even more fun, friends with whom either of us had e-mailed would send us a mail and then we'd reply and nope, into spam.

Gmail would do this for WEEKS and no amount of poking or begging or pleading would make it stop. And then it spontaneously would. So maybe the begging did work but was just delayed. I dunno. I tried signing up for Gmail's "Postmaster Tools" but no data was ever reported because "your mail volume is too low."

The ultimate ignominy? The final humiliation that sent me to Fastmail? I finally, through a couple of professional contacts, got to actually e-mail (via Gmail, of course, because they were blocking my personal domain again) with a real, live Gmail SMTP admin to ask why my latest round of e-mails were going into the bit bucket. Know what he said, even though my domain has been hosted on a server in the same colo facility with the same IP addresses for a decade? Something along the lines of "your domain reputation is coming back as too new."

Ladies and gentlemen, I give you whois:

google.com - Creation Date: 1997-09-15T04:00:00Z

mypersonaldomain-notreallythisvalue.org - Creation Date: 1997-03-10T05:00:00Z

Re: How to Run Your Own Mail Server (2017)

#218

I run my own mail infrastructure. To say the least I wouldn't recommend it even to my worst enemies. It's horrible. Actually it's fine until it's not. Then your email doesn't work and you could be missing out on important communications. And then you're scrambling to figure out how the spammers managed to exploit your setup this time. And you have to learn a tonne of crap in order to manage it... and the text files!…

See, for me running my own mailserver removes one of the biggest weaknesses with third party mail servers: the helpdesk. How many mail exploits are simple social engineering attacks against the service provider? Probably more than half.

Of course I still have to worry about attacks at my domain provider level, but at least it removes one weak point. I'm waiting for the day that someone pretended to be me calls me to get me to reset my mail account password.

Re: How to Run Your Own Mail Server (2017)

#219
post #53

Earlier quoted context omitted.

I've been running my own mail servers since the mid-90s, and always only a single server. SMTP keeps retrying, so you can be offline. The transport layer was designed to deliver mail to servers even if those servers only dialled in to one of the "internets" once per day, so it's fine to have some downtime. It's totally up to you how you prioritise getting a server back up again, and frankly if the message can't handl…

This is actually frustrating, e.g. with a large power outage when you expect an important message. I run my mailhost (single-node) since 2005 and I thought that I need HA more than once or twice. Sadly, I haven't figured out a proper fully-redundant solution. Syncing mailboxes with e.g. Syncthing is way too fragile. Recently, I wanted to experiment with DBMail + CockroachDB cluster but haven't yet found time for that…

Dovecot has an excellent implementation of 2-way synchronization of mailboxes: run Dovecot on 2 different servers in different physical locations, set up MX records and a SMTP software on both servers and you have your HA solution.

Re: How to Run Your Own Mail Server (2017)

#220
post #212
post #143

Earlier quoted context omitted.

"And then you're scrambling to figure out how the spammers managed to exploit your setup this time." ... " ... writing a MTA with the goal of minimizing configuration and being secure and resistant to attacks by default. " As a 20+ year UNIX sysadmin and fellow owner of my own email infrastructure for 18 of those, I am surprised to read this and am not even sure what you are talking about. Can you explain what you me…

I'm in the same boat - been running my own mail since the 90s. I could understand complaints about lots of weird hoops to jump through to get mail from your server accepted elsewhere - that has become harder over time[1] - but there's a very short list of things that need to be done to avoid being hijacked. Mail server setup for the uninitiated does look a little daunting, especially if you're more accustomed to "all…

On the plus side, do you really want to communicate with anyone who uses a SBCGlobal email address?
Post reply on HN