Fedora 34
Sponsored Link

Mail Server : Add Mail User Accounts (Virtual User)2021/05/21

 
Add Mail User Accounts to use Mail Service.
This example is for the case you use virtual mail-user accounts, not use OS accounts.
[1]
[2] Configure additional settings to Postfix and Dovecot.
# create a admin user for virtual mailboxes

[root@mail ~]#
useradd --uid 20000 --shell /sbin/nologin vmail
[root@mail ~]#
vi /etc/postfix/main.cf
# line 183 : comment out

#
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
# line 438 : change

home_mailbox =
/home/vmail/%d/%n/Maildir

# 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 : comment out

!include auth-passwdfile.conf.ext
# line 128 : comment out

!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 all [userdb] section

#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
[root@mail ~]#
systemctl restart postfix dovecot
[3] Add virtual mail user accounts.
[root@mail ~]#
vi /etc/postfix/virtual-mailbox
# create new

# [user account] [mailbox]

cent@srv.world   srv.world/cent/Maildir/
fedora@srv.world   srv.world/fedora/Maildir/
redhat@virtual.host   virtual.host/redhat/Maildir/

[root@mail ~]#
postmap /etc/postfix/virtual-mailbox
# generate encrypted 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]

cent@srv.world:{CRAM-MD5}xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
fedora@srv.world:{CRAM-MD5}xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
redhat@virtual.host:{CRAM-MD5}xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
[4] That's OK.
Verify to test to send emails with E-Mail client.
For settings on this example, specify email address for [Username] on Email Client settings.
Matched Content