Your own Debian Mail Server (part II): how to prove you are not a spammer
scaron.info
scaron.info
For anyone that has configured email servers, you know it is a headache, this tutorial makes it look easy but its only adressing a a tiny portion of the problem (albiet a important one) - email spoofing. (EDIT: it does mention spam assassin at the end so there's a little bit of info about spam filtering)
https://yunohost.org/#/whatsyunohost
YunoHost is a server operating system aiming to make self-hosting accessible to everyone. It is based on Debian GNU/Linux and is fully compatible with it.
Basically YunoHost automatically installs and configures some services around LDAP, and provides tools to administrate them.
It can thus be considered as a distribution, including the following software:
Nginx: a web server
Postfix: an SMTP e-mail server
Dovecot: an IMAP and a POP3 e-mail server
Amavis: an antispam
Metronome: an XMPP server
OpenLDAP
Bind: a DNS server
SSOwat: a Single Sign On (SSO) web authentication system
A backup system (not yet implemeted)It's not just a case of distributing postfix and a nice UI on top. That's what makes email difficult nowadays.
I ended up ditching the self hosting route and went with an Exchange Online hosted email subscription at $5 per month and never looked back.
It's not the easiest thing in the world, but it's far from brain surgery.
So far, it has done its job quite nicely. Just make sure you don't plan on installing it next to a webserver. Its installer hijacks port 80/443 with its own nginx webserver.
Recently, after discovering and playing with OpenSMTPD, I've started replacing Postfix with OpenSMTPD on null mailers and internal relays. My Postfix configuration is pretty much identical on all of those hosts and I've gotten it pretty polished over the years, but there's something about the simplicity of OpenSMTPD that I really like.
I don't envision moving from Postfix anytime soon on my main mail systems (which serve many, many domains and users). If I had a much simpler mail setup I would definitely consider it, though.
What would stop spammers from abusing this trust?
Pros: It provides a good enough webmail, a good (collaborative) calendar, LDAP integration, etc. Configuring SPF, DKIM and https/smtps/imaps was pretty easy (good official wiki docs).
Cons: Since it's a very "industry ready" kind of project, with lots of corporations using it, so the community forums can be very hit or miss. "Community" (free software) downloads are harder to find on their website, and the binary package is a bit annoying to keep up to date (does not use apt/yum).
Overall, I find it sufficiently turn-key and it "just works", while still being based on free software. I also feel comfortable recommending it to clients who want to move away from MS Exchange or Google Apps, since there are lots of Zimbra commercial providers out there who can support it.
ps: Zimbra/mail is not part of my main business focus, I only manage our mail server because I don't like depending on a 3rd-party for something as critical as mail.
The only thing it doesn't do automatically is buy an SSL certificate.
But the thing with a mail server is there are number of steps beyond installation. You need to configure SSL and spam filtering, then your DNS and SPF records. Then you need to test and ensure your mail is making it through. And a mail server requires constant attention. It's not a configure once and forget. You need to take care of spam filtering, anti virus, and ensuring your mail server is up pretty much 24/7 without break, as email is important and cannot be down. This can become a huge time sink, hence folks leaning towards hosted solutions like Gmail etc which take care of all of that for a small cost.
[1] https://www.flockport.com/apps/mailbox/
[2] https://www.flockport.com/using-the-flockport-mailserver/
That said, I'm really surprised at how many mail sending services there are. Sending mail really shouldn't be hard (and it isn't if you understand all the components, but it's still time-consuming enough to be a challenge for many). I am not one of those folks who believes email should be replaced by a whole new thing, but I do think a simplification of the stack would be lovely. How we do that without introducing even more new mail related standards is the conundrum.
So if you don't want to invest the setup and ongoing maintenance time, or get no pleasure from doing such , may I ask why you want a simple way to do all this at all?
Seems like you should just use fastmail or gmail or similar?
Configuring and running smtp isn't supposed to be super easy and fool proof. I think most systems that claim that will leave you with an unmaintained email solution that is likely not very secure and probably not being replicated or backed up, for starters, not mentioning all the actual things that go into making it all work reliably.
I'm not the person you replied to, but among the potential reasons would be privacy, reliability and sustainability.
Just the 3 you mentioned here, privacy, reliability and sustainability are not going to happen if you are doing a 1-click install, and don't understand how it works.
There's also iRedAdmin but it's not particularly 'free'.
mailserver is a part of my stack I need to be able to tweak and look behind the curtain at; one-size-fits-all is really hard with email.
Best mailsoftware I used so far. And ridiculously fast
From the Manual page[0]:
> Haraka makes no attempt to be a mail store (like Exchange or Postix/Exim/Qmail), a LDA, nor an IMAP server (like Dovecot or Courier). Haraka is typically used with such systems.
I think the desire to run one's own email server today mostly reflects a longing to re-discover the highly-accessible anarchy of the early Internet. Unfortunately, if that is ever to be found, it likely won't be in the form of complying with the highly-burdensome mostly-social requirements of our modern, well-centralized, email system. More likely, it will come from painting over it.
These sort of unspoken rules you mention are very largely due to combat spam. If anyone with port 25 open was trusted the amount of spam would be intolerable.
Seems sort of silly to want to use email without taking these steps to make it official as possible.
This is not some manipulative plot by google to get you to spend an extra 60 dollars a year, sorry.
I don't think the bigger end-user providers have been very involved in developing those kinds of policies. The NANAE crowd was/is mostly administrators of smaller and university servers, not Yahoo/AOL/Hotmail/Gmail administrators.
- a clean IP, not on RBL, not blacklisted elsewhere to the best of my knowledge (outlook.com tells you when you IP is bad)
- also accessible on IPv6
- both IPs having a proper rDNS on my domain
- supporting SSL on port 487 and 565, with a certificate from a known authority
- with DKIM and SPF both passing according to gmail
Yet it ends up in gmail spam folder. And I'm only sending email to myself and 2 other persons, so it's not even mass mailing.
I think there are other factors at play.
(I'm hoping I won't have to partake in this.)
So what I'm saying is, no, I don't want to link my domains to my Google account just so that I can send mails to them. And I'm going to hold out hoping that their systems are collecting enough trust in my domains and/or IP addresses in other ways so that it won't be necessary.
I discovered the following for outlook.com: https://postmaster.live.com/snds/index.aspx?wa=wsignin1.0
Are there similar tools for aol.com, yahoo.com and icloud.com? (to basically cover the big 5)
I then had a customer who actually had a Cisco support agreement log a case, and was promptly informed that I needed to create an account on abuse.net and register our domain to resolve the issue. I did, and it immediately resolved the issue.
It's a frustrating, terrible situation, where you follow every possible best practice you can find, and you're at the mercy of a third party you've never heard of. I get that RBLs are a similar situation, but you can usually identify when that's a cause.
I've had this recur over the years with 5-6 other domains, but there doesn't seem to be any pattern to it, it certainly isn't an issue with every domain.
If I am correct, gmail now defaults to a "don't trust an IP by default" procedure. If enough people get your emails in a spam folder and mark it as not being spam, the system will start trusting the IP address. It also has to do with volume.
This might be a good service offering.
If someone could operate a few hundred gmail accounts, they could let people send them messages and mark those messages as not being spam in order to train the filters.
Of course, those things are not guaranteeing delivery, but they play an important role.
I just recently had an issue where I tried to send an email to a someone I'd just met. The cc-part that went to my gmail-account got through fine. He didn't even receive spam. After I set up spf, I successfully sent an email to the exact same gmail address.
If gmail had rejected the mail, there'd be no problem -- then I'd know that I'd have to take action. Quietly eating the mail... not cool.
I wonder how long until the only way to send email into gmail/outlook is to set up routing rules that send email to gmail/outlook addresses by logging in to those respective services, and sending directly, bypassing traditional unauthenticated smtp... presumably setting up one "major" delivery would be enough, as gmail can't ignore outlook.com and vice-versa...
If you have the same clean ips from pre dkim/domainkeys days then don't lose them, or it may be an uphill battle which I would be surprised if you didn't engage dkim to aid in fighting at that point.
SPF and DKIM are neither necessary for mail delivery nor sufficient to assure delivery.
There is, in fact, nothing you can do to guarantee delivery of your mail once you offer it to another mail server. If the recipient doesn't like it, it will be dropped.
You can do lots of things to help. The most important is to not be a spammer. Don't send substantially the same mail to lots of people who haven't asked for it.
This statement, while true, is completely useless. Without SPF and DKIM email providers will view your emails with more suspicion, so that a larger percentage of your email ends up in spam even when it really isn't. SPF and DKIM do not guarantee delivery but they reduce the chance of your email being inappropriately recognized as spam.
Mailservers are simple, basically you can send with every domain available, however that won't work since other servers will handle that via SPF, RDNS or DKIM.
Then again, I've had my domain for 17 years, self hosting everything for 16 years (with the occasional IP change, but I think I've had the same IP now for almost ten years so go figure).
My ip/domain name was in no (public) black lists, however - when I finally set up SPF google stopped black-holing my email.
After I managed to get hold of admins of outlook.com via (I think, there were a few redundant hoops I jumped through):
https://support.microsoft.com/en-us/getsupport?oaspworkflow=...
Outlook.com/hotmail.com provisionally started accepting my email again. All this without my domain sending any spam the past few years.
Personally I think SPF is rather silly, but apparently it's considered an important filter-knob by certain services. I'd much rather gmail/outlook require valid certificates for smtp, and turn of plain-text, than all these add-on protocols that are supposed to avoid "forged sender"-type stuff.
Then I'd have to move over from cacert to a "real" cert, but hopefully that bar will be easier to clear once letsencrypt is up and running.
The spam complaint rate keeps being broken (around 0.3%) because of yahoo, and utilizing Sendgrid as an EPS, I'm afraid of losing ability to send.
At this point I would love to hear an opinion of a e-mail deliveribility expert/veteran, or someone who can help me get off the cloud and host own email server that will be well-configured and maintained. I'm aware this service might come with a hefty $ bill. Please contact me via my email in my profile.
</shameless plug for help>
https://www.exratione.com/2014/07/setting-up-spf-and-dkim-fo...
Works pretty well for post-queue but as soon as you try to pre-queue filter anything you're in deep trouble.
Has anyone tried compiling SpamAssassin or writing a faster version of it in another language? It was a long time since I played with perllibs but I seem to remember being able to load perl code into c programs.
>Has anyone tried compiling SpamAssassin or writing a faster version of it in another language?
How fast to you want it? I've been pumping roughly 20,000 emails per day through Spamassassin via maia[0], on a relatively moderate VPS. greylisting in front of it handles a huge portion of the load.[0] https://github.com/technion/maia_mailguard
Edit: Been a while since I checked. Actually yesterday's number was 98,000.
But if you're interested I'm talking around 62k mails a day. My experience with this amount has led me to use 64G RAM on each MX but that's only to handle a certain incident with very high load. Usually RAM usage is much lower than 64G and there's plenty of IO cache available.
It's a bit picky and horribly documented, but extremely fast and low on resources.
I also wrote about the effectiveness of the various blacklists out there as well (http://boston.conman.org/2015/05/11.1).
I used SpamAssassin ca. 2000-2008, then moved to Gmail, and recently went back to maintaining my non-@gmail.com addresses with my own mail setup, again with SA. In the last 30 days I got 43 spams delivered to my spam folders, 16 spams delivered to non-existing addresses at my domains (captured to prevent backscatter), and 101 spams rejected right away on the SMTP level due to high enough score, and IIRC zero delivered to my inbox (IIRC even across the last 2-3 months). I'm not sure why so few spams are even being sent to my handful of non-@gmail.com addresses, I've been using some of them on mailing lists for about 8 years now, too. (My single @gmail.com address gets about 40 spams in the Gmail spam folder per day.) I got 2 false "half-positives" in the last 30 days from the same company before training them (and 0 fp to the spam folder); I say half-positives sine I'm filtering mails with a low enough score to a "possible spam" folder, with the idea of reducing the amount of work for checking.
It took some effort to get everything working well (not the fault of SpamAssassin, except for pulling some hair about its relatively messy setup (quite complex and not very clean, so needs a calm mind when doing a non-standard setup)). I wrote some software[0] for this, though some people will shake their heads that I'm using djbdns and Qmail (my motivation for the latter is that I know its workings and that it's the original backend for qpsmtpd).
[0] https://github.com/pflanze/better-qmail-remote, https://github.com/pflanze/mailmover, (and https://github.com/pflanze/tinydns-scm for generating tinydns configurations programmatically using Scheme, including SPF records, once I get around cleaning up the code and pushing it here)
> as soon as you try to pre-queue filter anything you're in deep trouble.
I'm using qpsmtpd as the incoming SMTP server, which is also written in Perl, but it doesn't matter, as SpamAssassin offers a daemon approach (spamd) which even qpsmtpd uses, thus you just execute the small "spamc" program and pass the mail on stdin (or use a library that reimplements the protocol in the language of choice). Given this I see no reason to be in deep trouble, and rejecting spams during the SMTP stage works just fine for me.
PS. yes, you can also embed Perl in a C program, but why deal with the complexities of mixing languages in the same process when scanning a mail takes several seconds of real time and a sizable fraction of a second of CPU time, thus the IPC overhead is completely negligible.
It's been made clear to me, thanks to this thread, that I first and foremost need to explore greylisting in postfix before mail is passed to the proxy_filter. Secondly that I should explore dspam and rspamd as faster alternatives to SA.
(eg, my record is simply "mx -all". So if a host is listed as an MX for my domain, it's also a valid sender. mail-tester doesn't appear to understand 'a' or 'mx' entries, so fails this entirely.)
I'm on a Mac now.
mutt itself is kinda slow if you actually use its internal IMAP and SMTP features over the Internet (such as with Gmail). Instead, I used offlineimap to pull down all of my mail to the Mac and pointed mutt at the (Maildir) directory where it was stored (which was incredibly fast, as you might guess).
In addition, instead of having mutt send outbound mail directly to Gmail itself, I fed messages to msmtp (locally) and let that take care of sending them off to Gmail in the background.
That setup isn't for everybody, of course, but I was very happy with it. In particular, {processing/catching up on} all of the mailing lists I subscribe to was much, much quicker.
Oh and OS X server doesn't support anything newer than tls1.0.
So for these reasons my next mail server will be something more mainstream.