Mail Server : Add Mail Accounts (Virtual User)2021/09/14 |
Add Mail Accounts (Virtual User).
This example is for the case you use virtual mail-user accounts, not use OS user accounts.
|
|
[1] |
Configure
basic Postfix settings, and
basic Dovecot settings first.
|
[2] | Configure additional settings to Postfix and Dovecot. |
# create a admin user for virtual mailboxes root@mail:~# adduser --uid 20000 --disabled-password --disabled-login vmail
root@mail:~#
vi /etc/postfix/main.cf # line 185 : comment out # mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
# add to the end
# if specify multiple domains, specify comma or space separated
virtual_mailbox_domains = srv.world, virtual.host
virtual_mailbox_base = /home/vmail
virtual_mailbox_maps = hash:/etc/postfix/virtual-mailbox
virtual_uid_maps = static:20000
virtual_gid_maps = static:20000
root@mail:~#
vi /etc/dovecot/conf.d/10-auth.conf # line 100 : add auth_mechanisms = cram-md5 plain login
# line 122 : comment out # !include auth-system.conf.ext
# line 125 : uncomment !include auth-passwdfile.conf.ext # line 127 : uncomment !include auth-static.conf.ext
root@mail:~#
vi /etc/dovecot/conf.d/auth-passwdfile.conf.ext # line 8 : change
passdb {
driver = passwd-file
args = scheme=CRAM-MD5 username_format=%u /etc/dovecot/users
# line 11 : comment out [userdb] section all #userdb { # driver = passwd-file # args = username_format=%u /etc/dovecot/users #..... #..... #}
root@mail:~#
vi /etc/dovecot/conf.d/auth-static.conf.ext # line 21-24 : uncomment and change
userdb {
driver = static
args = uid=vmail gid=vmail home=/home/vmail/%d/%n
}
root@mail:~#
vi /etc/dovecot/conf.d/10-mail.conf # line 30 : change mail_location = maildir: /home/vmail/%d/%n/Maildir
systemctl restart postfix dovecot
|
[3] | Add virtual mail user accounts. |
root@mail:~#
vi /etc/postfix/virtual-mailbox # create new # [user account] [mailbox] debian@srv.world srv.world/debian/Maildir/ debian@virtual.host virtual.host/debian/Maildir/
root@mail:~#
postmap /etc/postfix/virtual-mailbox
# generate password root@mail:~# doveadm pw -s CRAM-MD5 Enter new password: Retype new password: {CRAM-MD5}xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
root@mail:~#
vi /etc/dovecot/users # create new # [user account] [password] debian@srv.world:{CRAM-MD5}xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx debian@virtual.host:{CRAM-MD5}xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
[4] | That's OK. Verify to test to send emails on Mail client. For this settings, specify email address for [Username] on Email Client settings. |
Sponsored Link |