Friday, May 9, 2008, 11:41 AM
This is the first entry in a series on how to build out a stable, easy to manage, multiple-domain mailserver. I personally use this to host mail for my clients, and can say that it works quite well with no problems. Postfix is the SMTP server, handling remote deliver of mail, as well as accepting incoming mail and delivering it to user's mailboxes. Dovecot is responsible for accepting POP and IMAP connections, and reads mailboxes and sends them out. I'll explore a few different avenues and optional features you can add or remove. The original inspiration for this article is from the Ubuntu Wiki.Installing Core Software
First, we'll want to install the core programs that will be our mailserver. To do this:
sudo aptitude install postfix mailx dovecot-common dovecot-imapd dovecot-pop3d whoisThis may take a few minutes to complete.
Configuring postfix
Now, we'll tell postfix how we want it to work. First, we're going to tell it where to store mail, and how to figure out what mailbox belongs to what user. Add the following lines to /etc/postfix/main.cf:
home_mailbox = Maildir/
virtual_mailbox_domains = /etc/postfix/vhosts
virtual_mailbox_base = /home/vmail
virtual_mailbox_maps = hash:/etc/postfix/vmaps
virtual_minimum_uid = 1000
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
The virtual lines all imply that we're not applying a specific domain, but that it needs to read various files to find the user/domain names that it accepts mail for. Let's go ahead and create those files:
/etc/postfix/vhosts: Here, insert a list of all the domains you're hosting, each on its own line. For example:
example.com
example.net
samurai-penguin.comand so on.
/etc/postfix/vmaps: Now we specify both the email addresses we host, and the paths to them. You should always use the domain.com/user paths to keep things straight. Example:
abuse@example.com example.com/abuse/
postmaster@example.com example.com/postmaster/
you@example.net example.net/you/IMPORTANT: Make sure to postmap the vmaps file every time you change it so that postfix can use it. Run the following command to do this:
sudo postmap /etc/postfix/vmapsFinally, we need to setup the mailbox user/group so that both postfix and dovecot can read the mail directories.
sudo groupadd -g 5000 vmail
sudo useradd -m -u 5000 -g 5000 -s /bin/bash vmailConfiguring Dovecot
For the dovecot configuration, there are a LOT of changes, so it's easier to simply copy over the configuration file. Download this file, backup your old /etc/dovecot/dovecot.conf file, and write this one.
Dovecot.conf
What this does, essentially, is make dovecot play by the same rules we just told postfix to play by as far as how to recieve mail, where to look, etc. We also tell it where to find it's username/password information.
Adding Users
Now it's time to actually create some users. This is a two step process(really 3). The first step is to add the domain name to postfix's /etc/postfix/vhosts file. If it's already there, then just skip that.
For sanity, take a look at the configuration formats for the dovecot users. In reality, you'll never have to touch these because we're going to automate the whole process.
/etc/dovecot/users
info@domain1.com::5000:5000::/home/vmail/domain1.com/:/bin/false::/etc/dovecot/passwd:
info@domain1.com:$1$G/FqlOG5$Vj0xmc9fKY.UVr8OWr/7C1As I mentioned, you can/should use this script to do it all for you. It takes care of adding the user to postfix and postmapping the config file, as well as setting the password for the dovecot user. Note that it doesn't actually create folders -- postfix will do that for us.
adddovecotuser
Copy this file to somewhere like /usr/local/bin, and make sure it's executable (chmod +x adddovecotuser). You have to run this script as root/sudo. To add a user:
sudo adddovecotuser user@domain.comSo long as the domain is in /etc/postfix/vhosts, that's it! You should now have a mailserver that can recieve mail for you. That's great and all, but there are still a few limitations which will be covered in subsequent HOWTO articles:
- No Spam Filtration
- No Blocklists
- No way to send mail from outside
- No Antivirus scanning
- No Webmail
Good luck, and feel free to post comments if you have any questions!
Random Entry




wow gold
wow gold
wow gold
wow gold
留学中介
留学法国
德国留学
澳大利亚签证
日本签证
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold
wow gold