25

I am looking for a simple way to install a mail server on my Ubuntu server. I would like to be able to receive and send emails though a webmail (e.g. roundcube).

I have a domain name. The web server already works without any problem.

When I googled "simple method to install mail server on Ubuntu", I arrive on blogs with literally hundreds of steps to install a mail server:

  1. A Mailserver on Ubuntu 12.04: Postfix, Dovecot, MySQL
  2. Creating a Mail Server on Ubuntu
  3. Postfix

But, for sure I will make a mistake, if I follow those tutorials, and it will be very very time consuming. Most of the steps look very easy to automate, though.

I've try several install methods:

sudo apt-get install dovecot-postfix

sudo tasksel install mail-server

But from there, I have no idea how to add email accounts, and test if it actually works.

Do you know if there is an automated way to install a mail server?

EDIT - NEW ANSWER

Mail-In-A-Box

A very interesting open source project that turns a ubuntu machine into an email server:

https://github.com/JoshData/mailinabox

Tim
  • 32,861
  • 27
  • 118
  • 178
oli
  • 293
  • 3
    It looks to me that you're trying to run a publicly accessible service which interacts with other servers while not willing to spend time learning about it and even much less to administer it. What will you do when it gets abused? How will you troubleshoot it without knowing rudimentary details about its operation? This is one of those things that should be left to a *nix admin who knows what they're doing. – Marcin Kaminski Dec 18 '12 at 03:19
  • 6
    @MartinOrda, I understand your point. However you could say the same for a web server. It is publicly available and it can be abused. Still, I can do "sudo apt-get install lamp^", find my ip, move my webpage to "/var/www/", and access it from anywhere. Those are three easy steps. Moreover, often, the most secured options are chosen by default. For the mail server, I believe that 90% of the setup steps described in the links I posted would be completely useless to teach me how to secure my mail server. At best, it can discourage noobies. But, it does not help anyone to learn how to secure it. – oli Dec 18 '12 at 03:39
  • Sure, of course it applies to other systems that interact with each other. With regards to securing services - to do so, you first need to understand the basics. If you really intend to run such an MTA you should look at the list of available choices, choose one that's packaged (ideally) for your distribution and has the features you want and that you feel you'd be comfortable working with. And then read the friendly manual, documentation, etc. which most likely explains how to test it and verify whether it's appropriately secured. If I had to recommend one to you - I'd say Postfix. – Marcin Kaminski Dec 18 '12 at 04:03
  • Please see my answer, @MartinOrda is correct. Running a mail server incorrectly, can lead to very serious fines, and in some rare cases jail time (though I don't think the jail time part has made it though the courts yet). Running in incorrectly configured web server won't hurt anyone but you. – coteyr Dec 19 '12 at 00:59
  • ...(Sorry, pressed enter) Running an incorrectly configured, publicly addressable mail server will get you literally BANNED from ever sending a deliverable email again. This happens all the time. I deal with it all the time. If you don't take your time to learn this piece of software correctly, you will end up in a whole mess of trouble, ranging from not being able to ever email from that domain again, to huge fines from various governments. For this reason, postfix is set to local delivery only. I can not stress enough, that you learn first with email servers on a local lan that... – coteyr Dec 19 '12 at 01:04
  • ... can not send to external addresses. People have gotten very serious about this, and there are MANY enforcement "agencies" in place to make sure that you get blacklisted with hours/days of first opening port 25 (actually your probably already pre-blacklisted). -- Keep in mind that my terms are generic and as jargon free as I can manage, so they are less accurate then I would like, but basically DON'T RUN A PUBLIC MAIL SERVER if you don't know what your doing. Learn on an internal mail server. – coteyr Dec 19 '12 at 01:07
  • @coteyr, so, how can I learn about it? I don't feel like all those installation tutorials will teach me anything about security, and not getting black-listed... – oli Dec 19 '12 at 01:10
  • There are two ways that work well. Education (paying some one to teach you i.e. collage, certification schools, etc.), or my personal favorite and the one I personally used to gain my meager understanding, get a job in email server admin, learn from a guru. -- You could also experiment with local deliver, it will let you "play around". – coteyr Dec 19 '12 at 01:14
  • @oli a mail server is far more complicated to configure than a simple web server... (not all web servers are simple but all mail servers are critical). Anyways Apache the way you said you can install it will only get you to the page "It Works" or to a simple website and a lot of other things will need more configuration (not always easy). It will open only 1 single port to public and doesn't need write access also there is no login on it. Very different of a mail server! A lot of (at least) spammers are interested in relaying with any mail server not only with interesting ones. – laurent Dec 19 '12 at 01:14
  • If you don't configure it right, soon your mail server will be a spammer and a virus sender, not speaking of other illegal activities that can happen through it anonymously (pirating user accounts for example). Another point to consider is that a web site is a place people "decide to go" to see it and e-mail they receive it without doing anything. – laurent Dec 19 '12 at 01:23

8 Answers8

14

This is the best/simple method.

sudo apt-get install postfix

That's it a mail server is installed.

Now administrating that mail server is a whole different story.

By default postfix will deliver and relay for all local user accounts. That should get you started. If you want something more complex then you REALLY REALLY need to read, study, learn, apprentice, etc. Mail servers are very very complex to setup correctly. Even when setup correctly they take constant supervision and monitoring. If your doing anything more then local delivery then I 100% recommend that you do not setup your own mail server.

Do not forget to setup DNS and SPF records if your going to be sending emails to non-local addresses. This is a bare minimum and will not result in deliverable mail to most ISPs.

Again, I strongly urge you to read, and fully understand what you are doing before you even attempt to run a public mail server. Keep in mind, that (at least in the US) you can be fined per email, for emails sent from your server incorrectly. This is rare but has happened. A more common effect is that you get blacklisted, shunned, and marked as a generally evil person and are banned from ever running an email server again (this happens quite frequently).

If your going to run a public server make sure you speak with your ISP/Hosting first. You will need, at a minimum a static IP and their permission. Most ISPs will block you 100% from every getting back on the internet for running an incorrectly configured mail server for an extended period of time.

I add all these warnings so that you know, local delivery, intranet delivery, your fine. Remote delivery, know what you are doing before you even attempt it. Incorrectly configured mail servers can bring on a whole world of disaster if not handled correctly.

coteyr
  • 18,288
  • You also seem to be looking for a MTA and MUA. These are very separate. There is no "easy" way because there are about 9 bazillion options out there. If you are truly serious about running your own mail server the speak with your ISP's logistics/integration team. They will have some solutions that you will need to implement to get started. IF your hosting at a VPS, then the VPS company will likely have very specific rules, and guidelines. – coteyr Dec 19 '12 at 01:12
  • 1
    It's not exactly a pompous answer because if you've ever tried it, it's a nightmare.

    However, It makes NO sense why it is so difficult. NONE. I should be able to open a port, and be done with it.

    – Jonathan Sep 03 '18 at 00:35
9

Zimbra is a great and easy to setup mailserver with collaboration, it might be a bit heavy for some people's needs, but the first time I installed it I had it up and running in under 30 min. It even has paid support, if you really need it.

Neojames
  • 1,704
4

If you are new to email server but still want to set up one. You can check out my blog page Tiny VPS Postfix.

It is a good starting point to learn, and you can expend the configuration for full setup in future.

What it does

  • Send/Receive mail for your domain
  • Forward all incoming email to another email address according to configuration.

What it does not

  • NO local account, all username@your-domain.com are configure for forwarding
  • NO webmail. You will be using third party email service (eg. Yahoo, GMail, etc)

IF this is what you want, THEN I will copy the instruction over here. ELSE I will just leave this answer as is.

John Siu
  • 2,581
  • 1
  • 19
  • 23
4

Mail-In-A-Box

A very interesting open source project that turns a ubuntu machine into an email server:

https://github.com/JoshData/mailinabox

oli
  • 293
2

I use the all-encompassing WEBMIN. Found here

It has different modules that you can incorporate (or not) into managing your server. These modules ie: Apache, RAID, Sendmail and the like are a plug-in for Webmin and therefore become manageable when installed. Webmin can also manage your current installations and reports.

This simple application is the administrators backbone for setting up VOIP, Mail, DATABASE, cloud, firewall and more.

You can keep it simple or roll with the big boys with this.

Any well played system administrator has used this or something like it. This IS the front-end GUI to A Mailserver on Ubuntu 12.04: Postfix, Dovecot, MySQL etc. enter image description here

Ringtail
  • 16,127
2

You should also consider one of the inspirations for "mailinabox," Drew Crawford's post on how to NSA-proof your email in 2 hours.

rfreytag
  • 123
1

This is not short but you won't find anything short. It is easy to follow and very easy to administer as the users, domains, forward tables will be virtual in MySQL. Mail users doesn't need a system account to login to POP or IMAP. Works with StartTLS or SSL.

It guides you to build the mysql queries and to hook them in postfix to use mysql as virtual backend and to install antivirus, anti-spam filters and webmail (SquirrelMail). There are various versions of the guide for different releases of Ubuntu.

http://www.howtoforge.com/virtual-users-and-domains-with-postfix-courier-mysql-and-squirrelmail-ubuntu-12.04-lts.

laurent
  • 6,779
-1

Ubuntu help / MailServer https://help.ubuntu.com/community/MailServer

Ubuntu official documentation is most of the time, easy enough.

  • Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – Braiam Sep 08 '13 at 16:27
  • Not only it theoretically answer the question. It is answering the question. – user457015 Sep 08 '13 at 23:12
  • Did you read the link that is included in the comment? – Braiam Sep 08 '13 at 23:20
  • I was looking for something simple to install... You have provided a long list of software to install, with so many steps to install each of them... A single mistake in only one step and nothing works.... I wanted something more all-in-one, with an easy configuration. – oli Sep 09 '13 at 01:09
  • Most of the step are copy/paste in the terminal. Is it not "easy" because it is not in a GUI ? – user457015 Sep 09 '13 at 02:04
  • @user457015, okay there are hundreds of lines to copy and paste. But from my experience, there is always something unexpected happening. Even when there or only a few dozens of line to copy paste, the probability of flawless execution is quite low. With hundreds, it is nil. If it was really as easy as that and always execute well, people would just make a shell script to execute... – oli Sep 13 '13 at 05:48