My VPS is running Ubuntu, and I'd like to be able to receive email to my domain.
How do I easily set up a mail server to do this?
This is how I've setup mail on our production machines. These are the criteria that we needed:
First, I want to address what would appear to be the easiest solution.
Several issues with this occurred when we tried this: First it installs Dovecot, which is fine for most, but we've deemed Courier to be the better of the two for our needs. Second, it utilizes Postfix which is great but we also need Exim as it's a more powerful MTA/SMTP server. Third, it installs MySQL - in the configuration I utilize we prefer flat files for configuration as it's one less breaking point. Think what would happen if MySQL crashed for some unknown reason. Otherwise the rest of the packages is pretty straight forward and easy to maintain for a small mail service (think 1-2 email domains total).
We stray slightly outside the path of normal configurations but it makes for easier management.
All of our mail is stored in
I also maintain a list of all the domains on the server in
This is more or less the easy part of the setup. Just install the
Install Exim with
(These lines will appear in different parts of the file, replace each accordingly)
Once that's complete rebuild the exim configuration with
Install Courier with
There honestly isn't much configuration outside the standard. You'll just need to create a user database.
Exim and Courier check a few places to see if a login or an incoming email are valid. Exim checks if the domain is listed as a local hostname, or if the domain is in
Creating Email Accounts
I eventually created several tools to streamline this process - but adding a new user goes to the tune of:
Then add the address to courier userdb - so they can log in
Make sure to replace the values where appropriate. Also -
This will prompt you for a password, enter the one you wish to use for the account.
Finally, generate the userdb hash/shadow files. Restart Courier and test if your changes work:
Should produce something similar to
If you see "Authentication FAILED: Operation not permitted" instead edit /etc/courier/authdaemonrc and add authuserdb to the authmodulelist line.
After all tests have been confirmed, restart the various services involved (
Creating email aliases
For each domain you should create a file in
What this says: If the incoming mail doesn't match any email account I have on file - then the mail should be failed and bounced with a message: "No user at this address". So all mail sent to say:
However, we have a few email address we wish to maintain elsewhere - say email@example.com - in order to do so we need to create
That way, even though firstname.lastname@example.org doesn't match any email accounts on the server, it matches in the
The easiest way is to run
Reading up on email services administration is absolutely recommendable though.
I don't have a "great answer" but you may find these links helpful https://help.ubuntu.com/community/PostfixBasicSetupHowto#Receiving Mail and https://help.ubuntu.com/community/Postfix
Just been doing this myself, you do indeed need postfix, and in my case I wanted an imap server as well so that I can use a a nice gui client (not mentioning any names) on another machine. I used these documents:
Dovecot (imap and pop3)
Its actually pretty simple, got it up and running in a few minutes and am receiving e-mails. This is also useful to check that everything is set up ok pingability.
Oh, and you will of course have to set up your dns entries correctly as below (based on the settings that worked for me):
Note the full stop at end of mail servers and insert your ip address and domain name where appropriate.