Monday, May 2, 2016

simplest way to setup mail server using postfix + dovecot

*** setup information ***
domain: host.mail
protocol: pop3, smtp
our network: 192.168.0.0/24


1- install necessary packages, if ask during installation for anything, just say no
$ sudo apt-get install postfix dovecot-pop3d

2- add user, usermail1, the first user can send/receive email
$ sudo useradd -m usermail1
$ sudo usermod -a -G mail usermail1

3- configure postfix by edit file
mydomain = host.mail
myorigin = $mydomain
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
append_dot_mydomain = no
readme_directory = no
smtpd_use_tls=no
myhostname = localhost
mydestination = localhost, localhost.localdomain, , localhost, $mydomain, localhost.$mydomain
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 192.168.0.0/24
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all


4- add usermail1  to file /etc/aliases, so that postfix know the user and its email address. the content is as below
postmaster:    root
usermail1:      usermail1@host.mail


- then run command newaliases to update the file
$ sudo newaliases

5- configure dovecot, there are many configuration file, but we only need to configure only the following
-/etc/dovecot/conf.d/10-auth.conf
auth_mechanisms = plain
disable_plaintext_auth = no
!include auth-system.conf.ext


-/etc/dovecot/conf.d/10-master.conf
service imap-login {
  inet_listener imap {
  }
  inet_listener imaps {
  }
}
service pop3-login {
  inet_listener pop3 {
    port = 110
  }
  inet_listener pop3s {
  }
}
service lmtp {
  unix_listener lmtp {
  }
}
service imap {
}
service pop3 {
}
service auth {
  unix_listener auth-userdb {
  }
}
service auth-worker {
}
service dict {
  unix_listener dict {
  }
}




5- restart both dovecot and postfix, you can have mail server that support pop3 and smtp, and one user usermail1, and if you want to add new users follow step 2 and step 4

$ sudo /etc/init.d/dovecot restart
$ sudo /etc/init.d/postfix restart

No comments:

Post a Comment