Postfix + Dovecot mailserver on Ubuntu
Tested on Ubuntu 12.10 VPS
We will create simple mailserver using postfix and dovecot. In current example we will use secure pop3 and smtp.
You should act as user so we are not adding this annoying "sudo" at the beginning of each command.
Install postfix
apt-get install postfix
NOTE: if you got the error: Package 'postfix' has no installation candidate. You should update the APT’s database:
apt-get update apt-get upgrade
Usually postfix will show you the initial config "ui" . But you can check and reconfigure in case something wrong :
dpkg-reconfigure postfix
Check the next details and change in case it neccessary:
Mail server configuration type: “Internet Site”. System mail name: mydomain.com Root and postmaster mail recipient: leave blank Other destinations to accept mail for: Add mydomain.com to the beginning of this comma-separated list. Force synchronous updates?: No Local networks: (All local subnets + Your Server IP Subnet)Usually you should add : <YourIP>/32 Use procmail?: No Mailbox size limit: “0″ Local address extension character: Leave as default. Internet protocols to use: all
Create first user that will be used for mail. Let;s create user "test" with password "test1" . Change this password to more complex.
useradd test passwd test
Create the place for user test mail.We will use Maildir format:
mkdir /home/test/Maildir postconf -e 'home_mailbox = Maildir/' export MAIL=/home/test/Maildir service postfix restart
Just to be sure that sendmail is stopped make the next:
service sendmail stop service postfix restart
Lets test if transport system working properly:
telnet localhost 25 Trying 127.0.0.1... Connected to localhost.localdomain. Escape character is '^]'. 220 mail.vpsget.us ESMTP Postfix (Ubuntu)
Send yourself a test message:
ehlo localhost mail from: root@localhost 250 2.1.0 Ok rcpt to: test@localhost 250 2.1.5 Ok data Subject: testmail test 123 . 250 2.0.0 Ok: queued as 51A803C4B0AB quit 221 2.0.0 Bye Connection closed by foreign host. You have mail in /home/test/Maildir
You can view this message with "mail" command. To use mail command install if not installed:
apt-get install heirloom-mailx apt-get install mailutils
Run mail.you should see the subject line of your message. Press 1 and Enter to read it.
mail Heirloom mailx version 12.5 6/20/10. Type ? for help. "/home/test/Maildir": 1 message 1 new >N 1 root@localhost Mon Jun 16 10:32 13/403 testmail ? 1
On this step postfix is working properly.
Now we need to install dovecot ,We will use mail storage with dovecot
sudo apt-get install dovecot-imapd