11 ms·
How to set up a mail server on a GNU / Linux system
- bwarp 15y agoThis is useful. I will review. I have traditionally used the instructions here which are very mature and have done me well for years: http://workaround.org/ispmail http://workaround.org/ispmail They are absolutely bomb proof.
- plaes 15y agoYeah, this one is a bit improved stack, because it contains fewer pieces in critical places (ie dovecot can do all the authentication + delivery).
- freehunter 15y agoDoes anyone here recommend building your own email system other than it being more private than hosted email? Are there any benefits (outside of privacy) to putting up your own email server?
- haydin 15y ago... and on a -somewhat- related note: Does anyone here recommend 'premium' e-mail hosting, such as Rackspace E-mail? (http://www.rackspace.com/apps/email_hosting/rackspace_email/ http://www.rackspace.com/apps/email_hosting/rackspace_email/). What are the benefits of such services? I am trying to understand the benefits of these premium e-mail services to a postfix on a self-managed VPS.
- mstevens 15y agoThe obvious one is that it saves you the hassle of running postfix on a self-managed VPS. And you do get rather more than just postfix - there's webmail, IMAP, etc, all managed for you.
- alexchamberlain 15y agoThe obvious benefit is they manage it for you.
- tildedave 15y agoOne major advantage of premium hosting services (and other SaaS providers such as SendGrid) is that for outgoing mail, your mail will be delivered and not marked as spam/blacklisted/dropped silently. Because of the low volume of outgoing mail from a VPS, it's very easy to end up on blacklists.
- loup-vaillant 15y agoWait, how does sending little emails can get your server blacklisted? Is it because they don't care about the small guy, or is there some technical reason ?
- tildedave 15y agoIt's really about how much a false positive affects your IP's reputation. When you are sending out a lot of email, recipients see a volume of mail. If a few of these get marked as spam, no big deal, you sent out 5,000 mails in an hour, of which 2-3 were marked as a false positive. If you are running your own VPS you are sending out comparatively fewer mails so the decision on whether you are a spammer or not is made with a lot less information -- and most recipients will assume you are a spammer immediately.
- enkrs 15y agoIt's mostly because you're not yet proved to be NOT spam. When you start a new mail server on an IP there's zero diference between a legimate email server and a spamhost. Your IP will not be in spamhaus and other blacklists, but you might get stuck in McAffee and other more enterpricey filters, especially if some other IPs in your subnet are known to send spam.
- LVB 15y agoWhat tildedave said. I was on the wrong end of blacklisting situation and it was extremely frustrating. First, you don't know that your customers aren't receiving the emails. Second, you have very little clout in getting things cleared up. Third, it's just a huge PITA that wastes a lot of time. I'm running a very small operation, but one bad instance of my IP being blacklisted prompted me to shell out the extra $3 /months to have Rackspace send my emails.
- jcurbo 15y agoI have used pobox.com for years for email. They have excellent spam filtering. They also have excellent remediation for the few false positives I've had over the years. I can also only remember a couple of times they've actually been down that I have noticed, and I access my email fairly constantly (at home and via my phone)
- bradfa 15y agoIf you only need a small handful of email addresses, often the hosted service can provide those for a lower (or similar) monthly cost to that of a VPS (assuming you're dedicating the VPS to just email). The blacklist issues others have pointed out are real. Some IPs are on blacklists and you will not be able to get them removed without an outrageous amount of leg work. Most of the premium email hosting places make sure they're not on those blacklists. Personally, I use FastMail.fm. I've gotten the impression that if TSHTF, they'll fix it fast. The price is reasonable. They're not Google. When I get a website up that can't be served via static pages, I'll be going the VPS or other cloud service, but for email, I'm much happier leaving that to a premium provider.
- alexchamberlain 15y agoI want to insert a custom app into the email pipeline. Is there any other way?
- mvip 15y agoSure it's possible if you host it yourself. Where do you want to insert it?
- freehunter 15y agoHe may have been replying to me by setting up a situation where hosting your own email would be beneficial.
- alexchamberlain 15y agoI did mean in the hosted case. I want a web hook.
- mvip 15y agoI'm not sure what you mean by a 'web hook.' Can you elaborate?
- alexchamberlain 15y agoEach time I recieve an email, I would like my app to parse and then POST the email to a web server in real time.
- warp 15y agoIf you want to be part of the e-mail pipeline, your application should use SMTP for both sending and recieving. Use a spam service such as spamhero.com or google postini as the MX for your domain so you do not have to do spam filtering yourself, have the spam filter service deliver the mail to your application (over SMTP). Your app can do whatever processing it needs to do, and then deliver the mail to the MX server of the ISP you're using to host your mail. This way you can use your app without any changes as a local smtp filter as well (e.g. if you're using something like amavis).
- mvip 15y agoSure there are benefits with having your own email system versus a hosted solution (ie. you have the data on your server(s)), but it comes with maintenance headaches too. We recently switched over to Atmail (http://atmail.com/ http://atmail.com/) after years of running Cyrus+Postfix (with various anti-spam tools). Atmail is kinda the best of two worlds -- you have control over your data, but the software is easy to maintain. Under the hood, Atmail is using standard Unix/Linux components (dovecot, exim, spamassasin etc), but makes it easy to maintain. For a few other companies I'm involved with, I've deployed Google Apps, just because it's dead simple and gives you no headache.
- pwaring 15y agoI've always run my own email for several reasons: 1. I can choose my domain (although nowadays that's not a problem - it was when I first started). 2. I can tweak spam and anti-virus filtering. 3. I can view the logs if I think something is wrong. 4. I can be as (in)tolerant of other mail servers as I want (I've noticed that Google is a bit lax in the rules it enforces with regards to rejecting mail). 5. I don't trust Google or other providers not to mine my email, or to back it up. 6. It's a useful learning experience.
- beachgeek 15y agoEarlier I had used dovecot+postfix for my personal email system. The advantages are that if you roll your own you can do whatever the heck you want. Huge disadvantage (other than the fact that power, static IP etc are all your problem) is that a LOT of email providers will think you are spam. Now I use SES for outgoing (for my app) and Gmail for incoming. Works a lot better. I remember reading that Gmail lets you write filters and what not as well, but I have not examined it in detail. I'm sure its do-able.
- phzbOx 15y agoI know it's a bit out of subject but I had to do this a couple time, and now, I simply use google app. It gets the job done, have a nice spam filter and more importantly, users are already used with google services. I'm not saying configuring the server with postfix is bad, far from that, but it might be worthwhile to look at google app as it may speed up things for you and your users.
- alexchamberlain 15y agoI use Google Apps for personal email, but I was thinking of building in secure and monitored messaging to an idea I'm developing. In order to do that, I need to setup my own SMTP server.
- billpatrianakos 15y agoNot necessarily. Isn't that what services like Sendgrid have popped for? I'm actually I'm the same boat as you with needing an app to send various notification emails which is why I'm reading this thread so I'm about to check out some 3rd party options now. I don't know about you but I always assume I'll have little to no users so I got a 512 Linode figuring I'd spare such a small server from doing so much work and buying a bigger slice when and if necessary. Besides the complexity of setting up an email server so your messages can be reliably received I'd go with a 3rd party to save the server from the load.
- mitchellhislop 15y agoHowever, this is a great alternative to people looking to host their own, with some of the recent moves Google has been making. Also, it increases the bus factor of your communications, which is never a bad thing.
- mseebach 15y agoI agree. I've been on Google Apps for about five years now, and I routinely configure an apps account for almost all domains I buy. Never had any problems. Never having a "the e-mail is down" call while on vacation (or, really, anytime) is awesome. I enjoyed "The Five Stages of Hosting" posted earlier (http://news.ycombinator.com/item?id=3526767 http://news.ycombinator.com/item?id=3526767). In that metaphor, Google Apps is the large, modern and comfortable house in a central location with most amenities and virtually rent free - only downside is that the landlord won't let you knock down the walls, and there's no way a grand piano will fit through the front door.
- zaa 15y agoInstall the same in a couple of minutes with http://www.iredmail.org/ http://www.iredmail.org/
- alexchamberlain 15y agoI don't want all of it though. You shouldn't be running a web server on your email server for instance.
- zaa 15y agoWeb server is installed for the web control panel, which can be disabled afterwards. I do like step by step guides as they provide a higher level of control, but after you've performed a setup like that 2-3 times, you start to lean towards more automated installs as iredmail or custom written scripts. So why maintain your own scripts when you can start with a ready made package.
- alexchamberlain 15y agoAnd the webmail...
- pwaring 15y agoYou can do the same with Symbiosis, which is just a bunch of Debian packages on top of lenny (and soon squeeze): http://symbiosis.bytemark.co.uk/docs/symbiosis.html http://symbiosis.bytemark.co.uk/docs/symbiosis.html
- agentgt 15y agoI just recently setup an email auto-responder with a custom email server (in Java) and I will say it was a goddamn PITA. I did use the cited article and also this one is good: http://rimuhosting.com/support/settingupemail.jsp?mta=postfix http://rimuhosting.com/support/settingupemail.jsp?mta=postfi... Some things that are rather important: 1. Name your email server with "mail" some where in the name. Seriously don't call your email server crapbox.snaphop.com :) 2. Although you can send email as a relay on many different ports (2525, 8025, 587 (ssl)) you can really only receive on port 25. 3. You better have a PTR / reverse dns setup. 4. It takes at least a couple of hours before email servers will acknowledge you. 5. You can get away with out a SPF for a little bit but you really need if your going to blast a crap load of emails. Use this to test: http://www.kitterman.com/spf/validate.html http://www.kitterman.com/spf/validate.html
- Corrado 15y agoA couple of more gottchas are: 6. Some (most?) hosting providers are black listed and getting other email systems to recognize you as a valid agent is getting tougher and tougher. 7. You have to provide your own fail-over, or purchase it from someone else.
- mrud 15y agoIf you can live with delayed messages there is not really a need for fail-over as most server will retry multiple times (default iirc multiple days). But you should have at least another email address available for example to communicate with your provider.
- RockyMcNuts 15y ago8. domain keys (DKIM) ? did this recently on EC2 and found these helpful http://pauldowman.com/2008/02/17/smtp-mail-from-ec2-web-server-setup/ http://pauldowman.com/2008/02/17/smtp-mail-from-ec2-web-serv... http://www.practicalclouds.com/content/guide/sending-email-ec2-instances http://www.practicalclouds.com/content/guide/sending-email-e... DKIM on Ubuntu - https://help.ubuntu.com/community/Postfix/DKIM https://help.ubuntu.com/community/Postfix/DKIM Microsoft SPF record creation wizard - http://www.microsoft.com/mscorp/safety/content/technologies/senderid/wizard/default.aspx http://www.microsoft.com/mscorp/safety/content/technologies/... not sending that much mail, but noticed after setting up SPF/DKIM/reverse DNS that the mail I sent to myself didn't end up in spam folders at gmail and hotmail etc., without having to send via a service like authsmtp.com.
- 2mur 15y agoFor personal projects I set up Google apps to handle inbound/outbound email for an admin email. Then postfix on the server in a null client configuration for outbound email only (eg. no-reply) type registration emails and so forth.
- alexchamberlain 15y agoOff topic: I hate noreply email addresses. Why not send it from yourself or customer services?
- phillmv 15y agoThe only valid reason I can think of is minimizing PLEASE UNSUBSCRIBE from your customer service spam filter.
- 2mur 15y agoFor personal projects I set up Google apps to handle inbound/outbound email for an admin email. Then postfix on the server in a null client configuration for outbound email only (eg. no-reply) type registration emails and so forth.
- gog 15y agohttp://gogs.info/books/debian-mail/chunked/ http://gogs.info/books/debian-mail/chunked/ This one was written by me, for Debian Squeeze...
- regularfry 15y agoPersonally, I hugely prefer exim+dovecot to postfix+courier. This guide is the one I follow: http://hinterlands.org/wiki/index.php/DebianEximDovecotSquirrelmailSieve http://hinterlands.org/wiki/index.php/DebianEximDovecotSquir... (although I'm not a Squirrelmail fan at all).
- Arelius 15y agoIMO, I agree with dovecot over courier, but any reason you prefer exim? I'm under the impression that postfix is regarded as one of the best examples of secure software to date.
- regularfry 15y agoHabit, mostly. The first mail server I ran for myself was postfix, and I managed to get in a nasty tangle. Exim configuration just seems to fit my brain better.
- ivan78 15y agoI have much better recipe. You go to zimbra.com, download ZCS Open-Source Edition and immediately have all the functionality out of the box. As a bonus you have much more beautiful web-interface than ancient Squirrelmail.
- jcurbo 15y agoSquirrelmail is indeed ancient looking. Years ago when I last ran my own mail stack (postfix + cyrus) I wondered why there wasn't a gmail-clone mail webapp. Perhaps there is now?
- capnrefsmmat 15y agoThere's Roundcube, which is reasonably good: http://roundcube.net/ http://roundcube.net/
- Joeboy 15y agoThe advice I wish somebody had given me: Don't use Debian's default configuration for Exim. Even though Debian's docs strongly recommend that you should do so. I'm sure their magic config stuff works brilliantly for somebody, but for most people it creates a vast, complex set of files that then breaks when you upgrade, leaving you with no email. Just write (or find) a config file.
- alexchamberlain 15y agoThis (almost) holds true for (almost) every piece of software.
- tsuraan 15y agoWhile in college, my housemates had a Linux mail server configured with individualized spam filtering; every user had an IMAP "spam" folder and a "ham" folder; they could move false negatives from their inbox to the spam folder, move false positives from spam to ham, and a nightly job would run and generate custom statistics for each user. It was remarkably slick, and for years I've been trying to figure out what that setup was. Does anybody have any ideas, or actual links to similar tutorials?
- pavel_lishin 15y agoI'd just e-mail them and ask them. (And hope that your email doesn't fall into the spam box :) )
- flopunctro 15y agoThe "spam" and "ham" IMAP folders correspond to a certain file or folder(1) on the server. Email users have the learning commands in crontab. These are as simple as "sa-learn --spam /path/to/spam_folder; sa-learn --ham /path/to/ham_folder". (1) file if the backend is mbox, folder if the backend is Maildir.
- yesbabyyes 15y agoWe did this for my old company, with Cyrus IMAPd and spamassassin. The mail directories are regular directories on the server, and then it's just a cronjob. I regret that we didn't think of Google's priority inbox, which would have been trivial to implement!
- BCM43 15y agoMake a cron job run this? http://spamassassin.apache.org/full/3.0.x/dist/doc/sa-learn.html http://spamassassin.apache.org/full/3.0.x/dist/doc/sa-learn....
- thehermit 15y agoI used this setup for years before switching to google apps using dovecot and dspam. Doing a quick search this seems to be very close and up to date. http://www.owlfish.com/thoughts/dovecot-antispam-2011-03-21.html http://www.owlfish.com/thoughts/dovecot-antispam-2011-03-21....
- trimbo 15y agoFor receiving email, why would you want to donate your bandwidth costs to spammers? I understand the desire to use Postfix though, so just use Gmail, or even Pobox (which has adjustable spam settings), then forward to your own server with some whitelisting in place. Then at least you've cut your bandwidth by about 99%. For sending email, there are some steps for DNS and signing missing here that can result in your email going to spam with the major ISPs. It looks like he was going to add Domain Keys in v6 but abandoned it.
- tlb 15y agoThe size of that guide illustrates why I switched to google apps + gmail. I was using a different stack based on FreeBSD, qmail, spamassassin, imapd and tcpserver, but about equally complex. It required regular maintenance and took up too much mental space.
- rabidsnail 15y agoWhenever I see a tutorial like this I think: "Why isn't this a script?".
- spydum 15y agoPeople still setup mail servers? amazing, I actually thought I was the last hold out to host my own email. I used to be all crazy into qmail (and then later postfix), with spamassassin, clamav, etc. It wasn't until about 5 years ago I ran into Surgemail while reviewing solutions for a former employer. http://netwinsite.com/surgemail/ http://netwinsite.com/surgemail/ it's worth a look if you are into hosting your own mail. I rarely, if ever plug commercial software, but these guys have really earned it. From their awesome support, development, and licensing model, it's just all around impressive.
- ilaksh 15y agoIn case it helps anyone who is like me and isn't concerned about the most secure or optimal setup for all aspects of email and just wants the easiest way to be able to send mail on Ubuntu, what worked for me was this: sudo apt-get install postfix Then hit enter a few times to select the defaults.
- corford 15y agoI've become a very big fan of www.zarafa.com over the last year or so. It's open source, modular, works hand in hand with postfix, supports activesync phones, has a great webmail interface, strong documentation and, best of all, fully supports Outlook 2010 clients connecting in Exchange mode (if you want that). IMHO, it's the best opensource groupware offering out there.
- deleted 15y ago[deleted]
- corford 15y agoFor anyone thinking of running a private mail server off their home DSL line, don't do it. It's very likely your IP (even if static) will be in all sorts of spam block lists. Instead, either use your ISPs mail server as a smarthost (if they allow it) or (better imho) get a small VPS of your own (e.g from Linode) and: 1). Install open dkim and set it to sign all your outgoing mail (make sure to add the relevant DKIM TXT records to your domains) 2). Add SPF records to all your domains 3). Make sure your server's IP has reverse dns setup Your mail should then happily sail through all but the most brutal of spam filters.
- sigpipe 15y agoI use my home server as the primary MX, and a VPS to relay outgoing mail via TLS and serve as a backup MX. This allows me to keep my email on a server only accessible to me, while avoiding the blocklist issues when sending mail.
- lgeek 15y agoIt's funny that I've just switched from Google Apps to my own email server today. I've used GApps since 2007, but I've been considering to move away for some time, mostly due to privacy concerns. It only took me a couple of hours to set up an encrypted VPS with Postfix and Dovecot, change the DNS and test that everything works ok. I'm somewhat lucky that I don't get too much spam and Thunderbird does a decent job of filtering it.
- clsdaniel 15y agoLong ago I installed a small server for a university project that ran on linux (slackware with many customizations), at the time configuring postfix, dovecot, exim, etc. Was a pain and probably not worth my time for what it was used so we decided to go with Hula which at the time looked promising, was dead simple to get working and fairly performant given the low end spec of the server (P4 1.8Ghz, 256mb RAM). Later on Hula struggled badly with Novell, was sold and forked, we tried to check out the forked version (Bongo I think) but so far the project seemed dead. After a while we did a clean setup after failing a distribution upgrade (but hey 5 years updating without hitch on custom kernel and compiled software), we moved to debian to lessen maintenance, email was done via postfix+dovecoat+postgresql, which was a hassle (to say at least) to configure, funny enough this setup did not perform well, looking for a more consolidated solution we found Apache James, which looked fairly promising (being under the Apache foundation), the only downside was that it was written in Java, not that I have anything against it but that is another vm to install and maintain, we gave it a try and we have been very satisfied with the results, easy to administrate, very sane defaults, relatively easy configuration in case of tweaks (having it use our postgresql db for users was pretty easy compared to postfix/dovecot), it sucks a lot of memory but the machine overall feels even faster that with the postfix/dovecot stack. So yeah, while its nice to have an email stack that follows the Unix philosophy, it can get very unwieldy for simple setups (while it may shine on complex setups where flexibility is needed).