X
    Categories Tutorials

Mailserver with virtual users and domains using Postfix and Dovecot on a CentOS 6 VPS

The following article will show you how to install and run simple POP3/IMAP/SMTP mail server in your CentOS VPS using virtual users and domains with Postfix and Dovecot

What is Postfix? It is a drop in replacement for the old and mature Sendmail. Postfix also attempts to be very fast, easy to administer, and secure.

What is Dovecot? It is an open source IMAP and POP3 server for *NIX-like systems, written primarily with security in mind.

PRE-REQ

You may want to check if your hostname/domainname is a valid FQDN (fully qualified domain name) and it has a valid MX DNS record.

## if ! type -path "dig" > /dev/null 2>&1; then yum install bind-utils -y; fi
## DOMAIN=mydomain.com
## NSHOSTS=( "$(dig @4.2.2.2 +short MX ${DOMAIN}|sort -n|cut -d' ' -f2)" )
## for NS in ${NSHOSTS[@]}; do printf "%-15s => %-s\n" "$(dig @4.2.2.2 +short A ${NS})" "${NS}"; done
## unset DOMAIN NSHOSTS

UPDATE THE SYSTEM

## screen -U -S mailserver-screen
## yum update

SET-UP SYSTEM USER

create group used for virtual mailboxes

## groupadd vmail -g 2222

create user used for virtual mailboxes

## useradd vmail -r -g 2222 -u 2222 -d /var/vmail -m -c "mail user"

INSTALL POSTFIX

## yum remove exim sendmail
## yum install postfix cronie

edit postfix main.cf configuration file

## cp /etc/postfix/main.cf{,.orig}
## vim /etc/postfix/main.cf
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
unknown_local_recipient_reject_code = 550
alias_maps = hash:/etc/postfix/aliases
alias_database = $alias_maps

inet_interfaces = all
inet_protocols = ipv4
mydestination = $myhostname, localhost.$mydomain, localhost

debug_peer_level = 2
debugger_command =
         PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
         ddd $daemon_directory/$process_name $process_id & sleep 5

sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.6.6/samples
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES

relay_domains = *
virtual_alias_maps=hash:/etc/postfix/vmail_aliases
virtual_mailbox_domains=hash:/etc/postfix/vmail_domains
virtual_mailbox_maps=hash:/etc/postfix/vmail_mailbox

virtual_mailbox_base = /var/vmail
virtual_minimum_uid = 2222
virtual_transport = virtual
virtual_uid_maps = static:2222
virtual_gid_maps = static:2222

smtpd_sasl_auth_enable = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = /var/run/dovecot/auth-client
smtpd_sasl_security_options = noanonymous
smtpd_sasl_tls_security_options = $smtpd_sasl_security_options
smtpd_sasl_local_domain = $mydomain
broken_sasl_auth_clients = yes

smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination

create vmail_domains configuration file. this is where you add your virtual domains.

## vim /etc/postfix/vmail_domains
mydomain.com            OK
my-otherdomain.com      OK

create vmail_mailbox configuration file. this is where you define your mailboxes.

## vim /etc/postfix/vmail_mailbox
info@mydomain.com           mydomain.com/info/
info@my-otherdomain.com     my-otherdomain.com/info/

create vmail_aliases configuration file. this is where you define your virtual aliases.

## vim /etc/postfix/vmail_aliases
info@mydomain.com           info@mydomain.com
info@my-otherdomain.com     foo@bar.tld

hash the configuration files

## postmap /etc/postfix/vmail_domains
## postmap /etc/postfix/vmail_mailbox
## postmap /etc/postfix/vmail_aliases
## touch /etc/postfix/aliases
## vim +/submission /etc/postfix/master.cf
submission inet n       -       n       -       -       smtpd

INSTALL DOVECOT

## yum install dovecot

edit dovecot dovecot.conf configuration file

## cp /etc/dovecot/dovecot.conf{,.orig}
## vim /etc/dovecot/dovecot.conf
listen = *
ssl = no
protocols = imap lmtp
disable_plaintext_auth = no
auth_mechanisms = plain login
mail_access_groups = vmail
default_login_user = vmail
first_valid_uid = 2222
first_valid_gid = 2222
#mail_location = maildir:~/Maildir
mail_location = maildir:/var/vmail/%d/%n

passdb {
    driver = passwd-file
    args = scheme=SHA1 /etc/dovecot/passwd
}
userdb {
    driver = static
    args = uid=2222 gid=2222 home=/var/vmail/%d/%n allow_all_users=yes
}
service auth {
    unix_listener auth-client {
        group = postfix
        mode = 0660
        user = postfix
    }
    user = root
}
service imap-login {
  process_min_avail = 1
  user = vmail
}

create virtual user’s configuration file passwd. this is where usernames and password hashes will be stored.

## touch /etc/dovecot/passwd
## doveadm pw -s sha1 | cut -d '}' -f2

## vim /etc/dovecot/passwd
info@mydomain.com:DOzcsKI8HY0bg8LAuz0DPKwS3WA=
## chown root: /etc/dovecot/passwd
## chmod 600 /etc/dovecot/passwd

START SERVICES

## chkconfig postfix on
## chkconfig dovecot on
## service postfix restart
## service dovecot restart

TEST THE SET-UP

Open your favorite e-mail client and configure it to use the newly created info@mydomain.com account. Try to send/receive an email. If you experience any issues, check if there’s something logged in /var/log/maillog

you can also use swaks to test your smtp server, for example:

swaks --to support@mydomain.com --from email@address.net

more information about swaks you can find at man swaks

ADD ANOTHER ACCOUNT

set-up account’s mailbox

## vim /etc/postfix/vmail_mailbox
...
support@mydomain.com           mydomain.com/support/

set-up account’s alias(es)

## vim /etc/postfix/vmail_aliases
...
support@mydomain.com           support@mydomain.com

postmap configuration files and restart postfix

## postmap /etc/postfix/vmail_mailbox
## postmap /etc/postfix/vmail_aliases
## service postfix restart

generate password hash and add username:password-hash to passwd file.

## doveadm pw -s sha1 | cut -d '}' -f2
## vim /etc/dovecot/passwd
...
support@mydomain.com:DOzcsKI8HY0bg8LAuz0DPKwS3WA=

This is a simple, but yet very robust mail server set-up on a CentOS 6 VPS which supports SMTP and IMAP without SSL, webmail, anti-spam, anti-virus, filter rules, opendkim etc. However, in the next few related articles, we will be adding additional features to the set-up to make it even yet more powerful, so stay tuned.


Of course, if you are one of our Linux VPS Hosting customers, you don’t have to do any of this, simply ask our admins, sit back and relax. Our admins will set this up for you immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

admin :

View Comments (85)

  • Hi,

    I have multiple MX records with different priority

    2 myCentOS7server. com xxx.xx.xx.xx
    1 aspmx.l.google. com 74.125.133.26 (no glue)

    I am trying to set mail server on myCentOS7server. com machine, I followed the document till last and tried to test this with below command

    swaks --to support@mydomain. com --from info@mydomain. com

    I got below after this command, and thunderbird is not recognizing the user email. Please help !!

    [root@server2 ~]# swaks --to support@mydomain. com --from info@mydomain. com
    === Trying aspmx.l.google. com:25...
    === Connected to aspmx.l.google. com.
    EHLO server2.mydomain. com
    <- 250-mx.google. com at your service, [XXX.XX.XXX.XXX]
    <- 250-SIZE 157286400
    <- 250-8BITMIME
    <- 250-STARTTLS
    <- 250-ENHANCEDSTATUSCODES
    <- 250-PIPELINING
    <- 250-CHUNKING
    MAIL FROM:
    RCPT TO:
    <** 550-5.1.1 The email account that you tried to reach does not exist. Please try
    <** 550-5.1.1 double-checking the recipient's email address for typos or
    <** 550-5.1.1 unnecessary spaces. Learn more at
    QUIT
    <- 221 2.0.0 closing connection c5si1527112edj. 392 - gsmtp
    === Connection closed with remote host.
    [root@server2 ~]#
    [root@server2 ~]# swaks --to info@mydomain. com --from support@mydomain. com
    === Trying aspmx.l.google. com:25...
    === Connected to aspmx.l.google. com.
    EHLO server2.mydomain. com
    <- 250-mx.google. com at your service, [XXX.XX.XXX.XXX]
    <- 250-SIZE 157286400
    <- 250-8BITMIME
    <- 250-STARTTLS
    <- 250-ENHANCEDSTATUSCODES
    <- 250-PIPELINING
    <- 250-CHUNKING
    MAIL FROM:
    RCPT TO:
    <** 550-5.1.1 The email account that you tried to reach does not exist. Please try
    <** 550-5.1.1 double-checking the recipient's email address for typos or
    <** 550-5.1.1 unnecessary spaces. Learn more at
    QUIT
    <- 221 2.0.0 closing connection x56si1388327edd.171 - gsmtp
    === Connection closed with remote host.

    • Hi Shobhit,

      We cannot tell you for sure what is causing the problem because we don't have access to your sever.

      You should check the mail server log files for more details.

  • Hi,

    I created 2 email accounts yesterday (info@mydomain.com & support@mydomain.com). I tried adding these mail accounts on Thunderbird today, and it worked. I can send/receive mails via Thunderbird between these two accounts.

    Now, I tried creating another account (Shobhit_Agarwal@mydomain.com) using the same process, as mentioned in the document. Next I tried below command and got below reply, which shows the new mailbox is sending the messages

    [root@server2 ~]# swaks --to Shobhit_Agarwal@mydomain.com --from info@mydomain.com
    === Trying aspmx.l.google.com:25...
    === Connected to aspmx.l.google.com.
    EHLO server2.mydomain.com
    <- 250-mx.google.com at your service, [XXX.XX.XXX.XXX]
    <- 250-SIZE 157286400
    <- 250-8BITMIME
    <- 250-STARTTLS
    <- 250-ENHANCEDSTATUSCODES
    <- 250-PIPELINING
    <- 250-CHUNKING
    MAIL FROM:
    RCPT TO:
    DATA
    Date: Thu, 24 Aug 2017 12:08:42 +0530
    -> To: Shobhit_Agarwal@mydomain.com
    -> From: info@mydomain.com
    -> Subject: test Thu, 24 Aug 2017 12:08:42 +0530
    -> Message-Id:
    -> X-Mailer: swaks v20170101.0 jetmore.org/john/code/swaks/
    ->
    -> This is a test mailing
    ->
    -> .
    QUIT
    <- 221 2.0.0 closing connection a61si3341241ede.223 - gsmtp
    === Connection closed with remote host.

    But, the issue is I am not able to configure this new mail account on the Thunderbird, it is saying "Username or Password is not correct), Does it takes time for the configuration settings to take effect after we create a new mail account?

    Below is the log from (/var/log/maillog) .

    Aug 24 01:33:38 server2 postfix/smtpd[30133]: connect from unknown[89.248.160.232]
    Aug 24 01:33:40 server2 postfix/smtpd[30133]: warning: unknown[89.248.160.232]: SASL LOGIN authentication failed: UGFzc3dvcmQ6
    Aug 24 01:33:40 server2 postfix/smtpd[30133]: disconnect from unknown[89.248.160.232]
    Aug 24 01:33:52 server2 dovecot: imap-login: Disconnected (auth failed, 3 attempts in 14 secs): user=, method=PLAIN, rip=52.230.27.222, lip=XXX.XXX.XXX.XXX, session=
    Aug 24 01:34:52 server2 postfix/smtpd[30133]: warning: hostname b3d9bc49.virtua.com.br does not resolve to address 179.217.188.73: Name or service not known
    Aug 24 01:34:52 server2 postfix/smtpd[30133]: connect from unknown[179.217.188.73]
    Aug 24 01:34:56 server2 postfix/smtpd[30133]: warning: unknown[179.217.188.73]: SASL LOGIN authentication failed: UGFzc3dvcmQ6
    Aug 24 01:34:56 server2 postfix/smtpd[30133]: disconnect from unknown[179.217.188.73]
    Aug 24 01:35:39 server2 postfix/smtpd[30133]: warning: hostname mta-89-248-160-232.mairtek.com does not resolve to address 89.248.160.232: Name or service not known

    Please suggest!!

  • Hi,

    I created 2 mail accounts (info@mydomain.com & support@mydomain.com), I tired configuring these 2 mail accounts on Thunderbird mail client and it worked for me. I can send/receive emails between these 2 accounts.

    I tried creating another email account following the steps in the later half of this post and tried configuring this new email account on Thunderbird, this time gave me error "Username or Password in unknown". Does it take some time for the changes to reflect?

  • Hello,

    I am not sure what changed in my CentOS 7 server in last 3 days, i was able to configure and send/receive emails, now I am not able to configure my thunderbird mail client for any email account. It is giving me error as "Configuration could not be verified – is the username or password wrong?"

    Please help!!

    Thanks

  • log from "tail -30 /var/log/maillog" is

    Aug 30 23:48:13 server2 postfix/smtpd[5861]: disconnect from unknown[52.230.27.222]
    Aug 30 23:48:18 server2 dovecot: imap-login: Login: user=, method=PLAIN, rip=52.230.27.222, lip=169.50.182.148, mpid=6031, session=
    Aug 30 23:48:18 server2 dovecot: imap(support@waterlilypond.co.uk): Error: user support@waterlilypond.co.uk: Initialization failed: Namespace '': mkdir(/var/vmail/waterlilypond.co.uk/support) failed: Permission denied (euid=2222(vmail) egid=2222(vmail) missing +w perm: /var/vmail/waterlilypond.co.uk, UNIX perms appear ok (ACL/MAC wrong?))
    Aug 30 23:48:18 server2 dovecot: imap(support@waterlilypond.co.uk): Error: Invalid user settings. Refer to server log for more information.
    Aug 30 23:48:21 server2 dovecot: imap-login: Login: user=, method=PLAIN, rip=52.230.27.222, lip=169.50.182.148, mpid=6051, session=
    Aug 30 23:48:21 server2 dovecot: imap(support@waterlilypond.co.uk): Error: user support@waterlilypond.co.uk: Initialization failed: Namespace '': mkdir(/var/vmail/waterlilypond.co.uk/support) failed: Permission denied (euid=2222(vmail) egid=2222(vmail) missing +w perm: /var/vmail/waterlilypond.co.uk, UNIX perms appear ok (ACL/MAC wrong?))
    Aug 30 23:48:21 server2 dovecot: imap(support@waterlilypond.co.uk): Error: Invalid user settings. Refer to server log for more information.
    Aug 30 23:48:33 server2 postfix/smtpd[6066]: warning: hostname supvigor.com.tw does not resolve to address 203.70.57.17
    Aug 30 23:48:33 server2 postfix/smtpd[6066]: connect from unknown[203.70.57.17]
    Aug 30 23:48:38 server2 postfix/smtpd[6066]: warning: unknown[203.70.57.17]: SASL LOGIN authentication failed: UGFzc3dvcmQ6
    Aug 30 23:48:38 server2 postfix/smtpd[6066]: disconnect from unknown[203.70.57.17]
    Aug 30 23:49:14 server2 postfix/smtpd[6130]: connect from unknown[52.230.27.222]
    Aug 30 23:49:14 server2 postfix/smtpd[6066]: connect from unknown[52.230.27.222]
    Aug 30 23:49:14 server2 postfix/smtpd[5861]: connect from unknown[52.230.27.222]
    Aug 30 23:49:14 server2 postfix/smtpd[6129]: connect from unknown[52.230.27.222]
    Aug 30 23:49:14 server2 dovecot: imap-login: Aborted login (no auth attempts in 0 secs): user=, rip=52.230.27.222, lip=169.50.182.148, session=
    Aug 30 23:49:14 server2 dovecot: imap-login: Aborted login (no auth attempts in 0 secs): user=, rip=52.230.27.222, lip=169.50.182.148, session=
    Aug 30 23:49:14 server2 postfix/smtpd[6130]: disconnect from unknown[52.230.27.222]
    Aug 30 23:49:14 server2 postfix/smtpd[6066]: disconnect from unknown[52.230.27.222]
    Aug 30 23:49:14 server2 postfix/smtpd[5861]: disconnect from unknown[52.230.27.222]
    Aug 30 23:49:14 server2 postfix/smtpd[6129]: disconnect from unknown[52.230.27.222]
    Aug 30 23:49:25 server2 dovecot: imap-login: Login: user=, method=PLAIN, rip=52.230.27.222, lip=169.50.182.148, mpid=6138, session=
    Aug 30 23:49:25 server2 dovecot: imap(shobhit@waterlilypond.co.uk): Error: user shobhit@waterlilypond.co.uk: Initialization failed: Namespace '': mkdir(/var/vmail/waterlilypond.co.uk/shobhit) failed: Permission denied (euid=2222(vmail) egid=2222(vmail) missing +w perm: /var/vmail/waterlilypond.co.uk, UNIX perms appear ok (ACL/MAC wrong?))
    Aug 30 23:49:25 server2 dovecot: imap(shobhit@waterlilypond.co.uk): Error: Invalid user settings. Refer to server log for more information.
    Aug 30 23:49:28 server2 dovecot: imap-login: Login: user=, method=PLAIN, rip=52.230.27.222, lip=169.50.182.148, mpid=6158, session=
    Aug 30 23:49:28 server2 dovecot: imap(shobhit@waterlilypond.co.uk): Error: user shobhit@waterlilypond.co.uk: Initialization failed: Namespace '': mkdir(/var/vmail/waterlilypond.co.uk/shobhit) failed: Permission denied (euid=2222(vmail) egid=2222(vmail) missing +w perm: /var/vmail/waterlilypond.co.uk, UNIX perms appear ok (ACL/MAC wrong?))
    Aug 30 23:49:28 server2 dovecot: imap(shobhit@waterlilypond.co.uk): Error: Invalid user settings. Refer to server log for more information.
    Aug 30 23:49:32 server2 postfix/smtpd[5861]: connect from unknown[52.230.27.222]
    Aug 30 23:49:32 server2 dovecot: imap-login: Aborted login (no auth attempts in 0 secs): user=, rip=52.230.27.222, lip=169.50.182.148, session=
    Aug 30 23:49:32 server2 postfix/smtpd[5861]: disconnect from unknown[52.230.27.222]

  • Hi,

    So, it seemed like the first issue is resolved now.

    I tried creating virtual email accounts (pqr@waterlilypond.co.uk)using below commands :

    vim /etc/postfix/vmail_mailbox
    vim /etc/postfix/vmail_aliases

    and then created a hash password for my new email account and saved it in (vim /etc/dovecot/users).

    Then I tried, checking if my postfix is working for this newly created account. I test this by sending a Test email from root account (using below command), and the mail successfully reached my new mail directory inside (/var/v_mail/vhosts/waterlilypond.co.uk/pqr/new)

    echo "Test mail from postfix" | mail -s "Test Postfix" pqr@waterlilypond.co.uk

    Now, i tried configuring my mail client (Thunderbird) again from my desktop . It gave me same error as before : Error : Configuration could not be verified – is the username or password wrong?

    After this i checked my maillog file but, didn't see any log for authentication issue, rather below are the logs when i tried connecting my mail client.

    Sep 1 00:28:01 server2 postfix/smtpd[24448]: warning: hostname abts-kk-dynamic-141.217.171.122-airtelbroadband.in does not resolve to address 122.171.217.141: Name or service not known
    Sep 1 00:28:01 server2 postfix/smtpd[24448]: connect from unknown[122.171.217.141]
    Sep 1 00:28:01 server2 postfix/smtpd[24454]: warning: hostname abts-kk-dynamic-141.217.171.122-airtelbroadband.in does not resolve to address 122.171.217.141: Name or service not known
    Sep 1 00:28:01 server2 postfix/smtpd[24454]: connect from unknown[122.171.217.141]
    Sep 1 00:28:01 server2 postfix/smtpd[24448]: improper command pipelining after EHLO from unknown[122.171.217.141]: QUIT\r\n
    Sep 1 00:28:01 server2 postfix/smtpd[24448]: disconnect from unknown[122.171.217.141]
    Sep 1 00:28:01 server2 postfix/smtpd[24454]: disconnect from unknown[122.171.217.141]
    Sep 1 00:28:01 server2 postfix/smtpd[24449]: warning: hostname abts-kk-dynamic-141.217.171.122-airtelbroadband.in does not resolve to address 122.171.217.141: Name or service not known
    Sep 1 00:28:01 server2 postfix/smtpd[24449]: connect from unknown[122.171.217.141]
    Sep 1 00:28:01 server2 postfix/smtpd[24452]: warning: hostname abts-kk-dynamic-141.217.171.122-airtelbroadband.in does not resolve to address 122.171.217.141: Name or service not known
    Sep 1 00:28:01 server2 postfix/smtpd[24452]: connect from unknown[122.171.217.141]
    Sep 1 00:28:01 server2 postfix/smtpd[24449]: improper command pipelining after EHLO from unknown[122.171.217.141]: QUIT\r\n
    Sep 1 00:28:01 server2 postfix/smtpd[24449]: disconnect from unknown[122.171.217.141]
    Sep 1 00:28:02 server2 postfix/smtpd[24452]: disconnect from unknown[122.171.217.141]

    Please suggest, how can i check if my dovecot is working fine?

    Thanks,
    Shobhit

  • Hi, I figured it out and it was a permission issue under "vmail" directory. The issue is resolved now. Many thanks for pointing me to the correct direction.

    I now have one more problem.

    One of the user "abc@mydomain.com" is using G-suit as an email provider. So, I don't want to create this user in my vmail_mailbox and continue with his g-suit. I have multiple MX records, first preference is being used by Google, second preference MX record is given to my CentOS mail server.

    The issue is, when I am trying to send email from any user hosted on CentOS mail server with @mydomain.com it is not sending the mail to abc@mydomain.com, because it is trying to search the vmailbox where this user doesn't exist. However we can receive mails from abc@mydomain.com.

    Also, I can send/receive email from outside domain to abc@mydomain.com.

    How can I force my postfix configuration, so that it should check all the MX records for all the users, so that if some users with the same domain (@mydomain.com) is using a different email provider and other users hosted inside vmailbox file can communicate with each other?

    My current postfix main.cf is

    alias_database = $alias_maps
    alias_maps = hash:/etc/postfix/aliases
    broken_sasl_auth_clients = yes
    command_directory = /usr/sbin
    config_directory = /etc/postfix
    daemon_directory = /usr/libexec/postfix
    data_directory = /var/lib/postfix
    debug_peer_level = 2
    debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5
    default_process_limit = 100
    header_size_limit = 51200
    home_mailbox = Maildir/
    html_directory = no
    inet_interfaces = all
    inet_protocols = ipv4
    mail_owner = postfix
    mailq_path = /usr/bin/mailq.postfix
    manpage_directory = /usr/share/man
    message_size_limit = 10485760
    mydestination = $myhostname, localhost.$mydomain, localhost
    newaliases_path = /usr/bin/newaliases.postfix
    queue_directory = /var/spool/postfix
    queue_minfree = 20971520
    readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES
    relay_domains = *
    sample_directory = /usr/share/doc/postfix-2.10.1/samples
    sendmail_path = /usr/sbin/sendmail.postfix
    setgid_group = postdrop
    smtpd_client_connection_count_limit = 10
    smtpd_client_connection_rate_limit = 30
    smtpd_recipient_limit = 100
    smtpd_recipient_restrictions = reject_unauth_pipelining,reject_non_fqdn_recipient,reject_unknown_recipient_domain,permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination,permit
    smtpd_relay_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination,permit
    smtpd_sasl_auth_enable = yes
    smtpd_sasl_local_domain = $mydomain
    smtpd_sasl_path = /var/run/dovecot/auth-client
    smtpd_sasl_security_options = noanonymous
    smtpd_sasl_tls_security_options = $smtpd_sasl_security_options
    smtpd_sasl_type = dovecot
    smtpd_sender_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_non_fqdn_sender,reject_unknown_sender_domain,permit
    smtpd_tls_auth_only = no
    smtpd_tls_cert_file = /etc/postfix/GeoTrustSSL/waterlilypond.crt
    smtpd_tls_key_file = /etc/postfix/GeoTrustSSL/waterlilypond.key
    smtpd_tls_loglevel = 0
    smtpd_tls_received_header = yes
    smtpd_tls_security_level = may
    smtpd_tls_session_cache_timeout = 3600s
    smtpd_use_tls = yes
    tls_random_source = dev:/dev/urandom
    unknown_local_recipient_reject_code = 550
    virtual_alias_maps = hash:/etc/postfix/vmail_aliases
    virtual_gid_maps = static:2223
    virtual_mailbox_base = /var/v_mail/vhosts
    virtual_mailbox_domains = hash:/etc/postfix/vmail_domains
    virtual_mailbox_maps = hash:/etc/postfix/vmail_mailbox
    virtual_minimum_uid = 2223
    virtual_transport = virtual
    virtual_uid_maps = static:2223

    • The MX records need to be directed to a single mail server per domain or sub-domain. You cannot set up different MX records for different email users/accounts.

  • Hi, my question is how can I force my postfix to use all the MX records? Right now, what i believe is the postfix is only checking the default MX record for local domain.

    One user of my our company is using G-Suit as a mail server provider with email "user1@waterlilypond.co.uk", other users are using the mail server created using postfix/dovecot. There email accounts are created under virtual_mailboxes file eg "user2@waterlilypond.co.uk" and "user3@waterlilypond.co.uk"

    The scenarios which are PASSED :

    mail from : user2@waterlilypond.co.uk mail to : user3@waterlilypond.co.uk WORKING FINE
    mail from : user2@waterlilypond.co.uk mail to : anyuser@anydomai.com WORKING FINE
    mail from : user1@waterlilypond.co.uk mail to : user2@waterlilypond.co.uk WORKING FINE

    The scenario which is FAILING :

    mail from : user2@waterlilypond.co.uk mail to: user1@waterlilypond.co.uk Failing

    Error : 5.1.1 : Recipient address rejected : User unknow in virtual mailbox table.

    This is because the local mail server is trying to see the virtual mailbox for this user locally, which is not present as it is using G-Suit as email provider. How should I tell my postfix, to check the email address of other mail providers if the email account is not present inside local virtual mailbox?

    Please help!!

  • Hi,

    Thanks for the awesome sharing.

    I am done with the setup. I have successfully installed postfix, dovecot, roundcube.

    But, when I telnet on port 25, it does not work.

    telnet 25
    telnet: Unable to connect to remote host: Connection refused

    However, from server, I can telnet on port 25 with localhost.

    Can you please advise?