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

mailserver-with-virtual-users-and-domains-using-postfix-and-dovecot-in-centos-6The 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
[email protected]           mydomain.com/info/
[email protected]     my-otherdomain.com/info/

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

## vim /etc/postfix/vmail_aliases
[email protected]           [email protected]
[email protected]     [email protected]

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
[email protected]: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 [email protected] 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 [email protected] --from [email protected]

more information about swaks you can find at man swaks

ADD ANOTHER ACCOUNT

set-up account’s mailbox

## vim /etc/postfix/vmail_mailbox
...
[email protected]           mydomain.com/support/

set-up account’s alias(es)

## vim /etc/postfix/vmail_aliases
...
[email protected]           [email protected]

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
...
[email protected]: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.

95 thoughts on “Mailserver with virtual users and domains using Postfix and Dovecot on a CentOS 6 VPS”

  1. My configuration details

    /etc/postfix/vmail_domains
    indianrockers.net OK

    /etc/postfix/vmail_mailbox
    [email protected] indianrockers.net/webmaster/

    /etc/postfix/vmail_aliases
    [email protected] [email protected]

    When I executed “doveadm pw -s sha1 | cut -d ‘}’ -f2” I was asked for a password. I entered a password and confirmed it. Then I got a hash value.
    I opened /etc/dovecot/passwd and entered as follows.
    [email protected]:THEHASHVALUEIGOT

    In Thunderbird,
    Your name : IndianRockers
    Email address : [email protected]
    Password : Which I provided before getting the hash value.

    Error : Configuration could not be verified – is the username or password wrong?

    What am I doing wrong?

    Maillog

    Mar 2 02:14:09 indianrockers dovecot: imap-login: Login: user=, method=PLAIN, rip=***.***.***.***, lip=107.150.12.23, mpid=4262
    Mar 2 02:14:09 indianrockers dovecot: imap([email protected]): Error: chdir(/var/vmail/indianrockers.net/webmaster/) failed: Permission denied (euid=2222(<u$
    Mar 2 02:14:09 indianrockers dovecot: imap([email protected]): Error: chdir(/var/vmail/indianrockers.net/webmaster) failed: Permission denied
    Mar 2 02:14:09 indianrockers dovecot: imap([email protected]): Error: user [email protected]: Initialization failed: Initializing mail storage fro$
    Mar 2 02:14:09 indianrockers dovecot: imap([email protected]): Error: Invalid user settings. Refer to server log for more information.

    Reply
      • Hi, I am getting the same error as @mayasl mentioned. Here is what you asked for.

        #id vmail
        uid=2222(vmail) gid=2222(vmail) groups=2222(vmail)

        #ls -dl /var/vmail
        drwx——. 2 vmail vmail 4096 Apr 20 22:01 /var/vmail

        #ls -dl /var/vmail/vmail1
        ls: cannot access /var/vmail/vmail1: No such file or directory

        #dovecot -n
        # 2.0.9: /etc/dovecot/dovecot.conf
        # OS: Linux 2.6.32-431.11.2.el6.i686 i686 CentOS release 6.5 (Final) ext4
        auth_mechanisms = plain login
        default_login_user = vmail
        disable_plaintext_auth = no
        first_valid_gid = 2222
        first_valid_uid = 2222
        listen = *
        mail_access_groups = vmail
        mail_location = maildir:/var/vmail/%d/%n
        passdb {
        args = scheme=SHA1 /etc/dovecot/passwd
        driver = passwd-file
        }
        protocols = imap lmtp
        service auth {
        unix_listener auth-client {
        group = postfix
        mode = 0660
        user = postfix
        }
        user = root
        }
        service imap-login {
        process_min_avail = 1
        user = vmail
        }
        ssl = no
        userdb {
        args = uid=2222 gid=2222 home=/var/vmail/%d/%n allow_all_users=yes
        driver = static
        }

        Can you please help me. I have no idea where It went wrong

        Reply
        • Using Centos 6.5, postfix 2.6.6, dovecot 2.0.9 I need to add the following into dovecot.conf

          service auth {

          unix_listener auth-client {
          group = postfix
          mode = 0660
          user = postfix
          }


          unix_listener auth-master {
          group = vmail
          mode = 0660
          user = vmail
          }

          }

          Reply
  2. Followed Part 1 to 3 of this blog. Can’t seem to login via roundcube. Always get ‘Login failed’ error. Complete Linux newbie, so please advise how to troubleshoot/investigate further. Thank you.

    Reply
    • Make sure you complete all the steps correctly.

      Also, you could enable imap_debug in the main.inc.php and post the log of an attempted login.

      Reply
  3. Found out what was wrong. I deviated a little from the steps above. I put my custom config of dovecot in local.conf instead of dovecot.conf but forgot to uncomment the last line of dovecot.conf which includes configuration in local.conf.

    I have another question regarding roundcube webmail that I hope you can assist with. I deviated the configuration of postfix/dovecot a little (based on library.linode.com/email/postfix/postfix2.9.6-dovecot2.0.19-mysql) to store virtual domains, virtual accounts, passwords and virtual aliases in MySQL database. I understand roundcube webmail comes with password plugin that can allow user to change their passwords via the roundcube webmail interface and that it supports accounts/passwords stored in MySQL. Just not sure how to configure the plugin to fit with the MySQL schema as listed in the linode article.

    Reply
    • you have to enable the password plugin in your roundcube and configure it properly to match the db schema you are using. please check http://trac.roundcube.net/browser/github/plugins/password/README for more information.

      Reply
        • Roundcube have moved their old wiki to GitHub. Here’s the new link:
          https://github.com/roundcube/roundcubemail/blob/master/plugins/password/README

          Thank you for letting us know.

          Reply
  4. This guide is very sweet and it makes it very easy to get a server going.
    I have both an issue and a concern though.
    First of all: “relay_domains = *” sounds like a terribly bad idea, but I’m not really sure, I guess it won’t matter when login is required as specified by “auth_mechanisms = plain login”

    Now my issue which has nothing to do with the above:
    postfix expects /var/vmail/%d/%u to be a file and dovecot sets it up as a directory. What do I do here? Postfix can’t deliver e-mail because %d/%u is a directory and not a file. If I delete it and create it the mail is delivered but I cannot log in to the IMAP server.

    Reply
    • About “relay_domains = *”; You need to add the list of the domains your server will relay mail to, e.g:

      relay_domains = your-domain1.com, your-domain2.com

      As for the ‘mail_location’ problem, can you please provide us with your ‘/etc/dovecot/dovecot.conf’ Dovecot configuration file?

      Reply
  5. Did part 1
    Went fine but cannot check mail server connection since i get the following:
    “Log onto incoming mail server (POP3): Outlook cannot connect to your incoming (POP3) e-mail server. If you continue to receive this message, contact your server administrator or Internet service provider (ISP).”

    cat /var/log/maillog gives this:
    warning: maildir access problem for UID/GID=2222/2222: create maildir file /var/vmail/prosyde.net/info/tmp/1394210401.P2283.prosyde-mail: Permission denied

    checked /var/vmail and it is ok
    drwxrwxrwx. 2 vmail vmail 4096 Mar 7 11:47 /var/vmail

    What did i do wrong?

    Regards

    Reply
    • Something is not configured OK. Re-check your dovecot and postfix configuration files and make sure they use UID/GID 2222 to manage the mailboxes in /var/vmail

      Reply
  6. I think my previous comment didn’t go through. I have done all you have asked but when I try to log in using thunderbird, I get an error saying: “error : Configuration could not be verified – is the username or password wrong?”

    What could be the problem? Are you sure the password hashing is correct?

    Reply
      • Yes. Here is the error I get.
        pastebin.com/Uc9MhqAD

        Can you please help me? I am trying your tutorial on a fresh install VPS, running CentOS 6.5, 32but, Minimal, running postfix, devcot. Simply, server and A record and MX record wise everything is going smoothly.

        Reply
          • Ok, I reinstalled my VPS for the 4th time, and followed again your tutorials, still the same error for one week. Here is the output for `ls -al /var/vmail`

            [[email protected] /]# ls -al /var/vmail
            total 20
            drwxrwxrwx. 2 vmail vmail 4096 Apr 23 16:28 .
            drwxr-xr-x. 18 root root 4096 Apr 23 16:28 ..
            -rwxrwxrwx. 1 vmail vmail 18 Jul 18 2013 .bash_logout
            -rwxrwxrwx. 1 vmail vmail 176 Jul 18 2013 .bash_profile
            -rwxrwxrwx. 1 vmail vmail 124 Jul 18 2013 .bashrc
            [[email protected] /]#

            I’m convinced this method does NOT work for CentOs 6.5. I wish I had known that a week ago. Please include that in your tutorial to save some people time, and yourself same questions. I will check back one more time.
            Thanks for the reply.

          • We double-checked the tutorial and can confirm that it is working on CentOS 6.5. These are the correct permissions:

            # ls -al /var/vmail/
            total 24
            drwx—— 3 vmail vmail 4096 Apr 24 04:24 .
            drwxr-xr-x 22 root root 4096 Apr 24 04:09 ..
            -rw-r–r– 1 vmail vmail 18 Jul 18 2013 .bash_logout
            -rw-r–r– 1 vmail vmail 176 Jul 18 2013 .bash_profile
            -rw-r–r– 1 vmail vmail 124 Jul 18 2013 .bashrc
            drwx—— 3 vmail vmail 4096 Apr 24 04:24 mydomain.com

            Please read the tutorial very carefully and make sure you follow the simple instructions. Of course, you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to install this for you.

            Thanks.

  7. Apr 27 19:11:37 abc postfix/virtual[478563]: 330822209AE: to=, relay=virtual, delay=0.92, delays=0.81/0.01/0/0.1, dsn=2.0.0, status=sent (delivered to mailbox)

    postfix delivering but not showing while connected via pop3

    Reply
  8. It finally worked. Here is the trick. Don’t create e-mail account with the same name as one described in MYDOMAIN=

    If your MYDOMAIN=foobartar.com
    then creating [email protected] will cause some problems.

    Reply
  9. Why is it that If I use DOMAIN=web101.com then I won’t be able to receive any email created for that domain? Do you have a solution for this? With other domains everything works, but not for the domain mentioned. I would love to know a work-around for this.

    Thanks.

    Reply
    • Hi, simon.

      Unfortunately, we are not sure what exactly are you talking about? How did you mean if you use web101 . com you are not able to receive emails? What error message did you get? Did you check your mailserver log file? Are you sure you have your MX records set-up correctly?

      You need to provide more information and relevant sections from your log files so we can help.

      Reply
      • In your tutorial above, you have wrote a line where it says

        # DOMAIN=mydomain.com

        I substituted the above with my domain name. Let just say my domain is web101.com. So, according to your instructions, my I set

        # DOMAIN=web101.com

        So, now the problem is that I created an email for that domain. ex: [email protected], [email protected] … in the same way I created for other domains. But, all those emails associated for the domain web101.com do not work. Including those I mentioned.

        Reply
  10. First thank you for writing this awesome tutorial.
    I have followed the steps, and most of it seems to work fine. I have sent an email to my address and it appears on my maillog without error. My only problem is nothing is generated in the actual virtual_mailbox_base folder, it stays empty. my postfix config
    below is what appeared in my log
    May 22 05:54:45 styluxinc postfix/smtpd[20782]: A9E2274B81: client=mail-oa0-f54.google.com[209.85.219.54]
    May 22 05:54:45 styluxinc postfix/cleanup[20786]: A9E2274B81: message-id=
    May 22 05:54:45 styluxinc postfix/qmgr[20777]: A9E2274B81: from=, size=2379, nrcpt=1 (queue active)
    May 22 05:54:45 styluxinc postfix/local[20787]: A9E2274B81: to=, relay=local, delay=0.14, delays=0.13/0.01/0/0, dsn=2.0.0, status=sent (delivered to mailbox)
    May 22 05:54:45 styluxinc postfix/qmgr[20777]: A9E2274B81: removed

    Reply
  11. Hey!

    Can I pls get some help regarding MX records?

    I don´t know how to configure it, should I put the MX records in both zone files or just one of them?
    And what should I type?

    I know it should be something like:

    name IN MX [Preference number] host

    But what should be in the name column and what should be in the host column, PLS HELP!! Soooo confused :(

    Reply
    • You need to edit the forward zone containing authoritative information for your domain.

      name – usually it is your domain name (this name appears after the ‘@’ in an email address).
      host – a hostname or FQDN (not IP address) of a mail server that will accept mail.

      Please note, the DNS specification (RFC 2181) does not allow for an MX record to be a CNAME.

      Reply
  12. Hi ..!!
    i have installed/configured postfix mail server and now i want to send mass mails, is there option to break those bulk mails into single mails and queue 1000 recipients to one after the other ?

    Reply
  13. Hi!

    First of all – this is really great tutorial. I’ve been able to install everything without any problems.
    I can login via imap to my email account, but I can’t receive any email. I think i have the same problem as Steen had. In my error log it says:
    delivery failed to mailbox /var/vmail/testdomain.pl/test: cannot open file: Is a directory

    How to fix this error?

    Reply
  14. I`m using CentOS 6.4 x64 and I just finished with tutorial – from one with installing LAMP, thru this one.
    All worked fine except one little change in config file of postfix (maybe new version or something).
    I sent test mail and received it in inbox on yahoo (not going in SPAM folder – YAY, my MX record is working great), but when I did reply – mail delivery system returned mail to yahoo saying: unknow user: xxxx …
    Then I just changed one line in /etc/postfix/main.cf :
    mydestination = localhost
    and it`s working great xD

    Thx for making this wonderfull tutorial, I will bookmark it for life! Cheers!!!

    Reply
  15. All works. Thanks. But why does every message I send to any domain other than my own, gets sent to spam folder?

    Reply
  16. The BEST tutorial!

    I try from years! Many tutorials. But all of them Not working prorerly/all or part of them/

    This is first tutorial which working OK! Mails rich their destination even without SPF and reverse DNS

    Thanks!

    Reply
  17. After creating the file aliases, I needed to generate the hash for the file with postalias command. Without that postfix was crashing by the time I tried send an email.

    ## touch /etc/postfix/aliases
    ## postalias /etc/postfix/aliases

    Reply
  18. Thank You For Your tutorial. I tried it step by step, but still have some problems~My system OS is CentOS6.5~I can login and send Email successfuly, but I could not receive email correctly><There's nothing in my inbox~When I send an email from other web servers such as gmail, It shows that mail has been sent succestifully , but still nothing in my inbox… Anyone has the same problem?

    Reply
    • hi,

      verify you’ve configured postfix and dovecot correctly, check your ‘mail_location’ and check if the email is stored there. also, please post relevant lines from the log file so we can help.

      thanks

      Reply
  19. I am also having trouble with receiving mail. It doesn’t seem like nobody ever gets a working solution cause they don’t know how to reply. Anyways, if I could get some help that’d be great.

    Currently my mail_location is set to: ‘mail_location = maildir:/var/vmail/%d%n’

    When I send test emails from gmail to server email, it doesn’t return with any error at all.

    This here is out of the /var/log/maillog:

    Oct 13 12:45:44 localhost postfix/smtpd[981]: initializing the server-side TLS engine
    Oct 13 12:45:44 localhost postfix/smtpd[981]: connect from unknown[unknown]
    Oct 13 12:45:44 localhost postfix/smtpd[981]: lost connection after CONNECT from unknown[unknown]
    Oct 13 12:45:44 localhost postfix/smtpd[981]: disconnect from unknown[unknown]

    There is nothing out of the ordinary in the entire log, as I just cleared it to, so I can be more precise to see how the logs are performing upon me sending an email from gmail.

    Currently in cloudflare, here is what I got setup: http://i.imgur.com/HDrvJbd.png

    I have followed all 6 tutorials on the web mail setup exactly.

    Please if you could, inform me on what I can do to resolve this issue.

    Added:
    So I got a relay message back from Google now, this is what it displays: http://puu.sh/cbsm1/d5e22b04fd.png

    Reply
  20. Thanks for your great tutorial. Best one I’ve seen so far. I’ve set up everything and seems to be working fine. I want to retrieve my mails using gmail pop3 but I get a connection refused error on gmail. I assume because pop3 isn’t added on the dovecoat protocols. When I add it and try again I get a ‘authentication failed’ on gmail. Any idea what am doing wrong?

    Reply
  21. Jan 31 15:44:34 xxxxxx postfix/qmgr[24552]: E7E343A479: from=, size=3100, nrcpt=2 (queue active)
    Jan 31 15:44:34 xxxxxxx postfix/local[24706]: E7E343A479: to=, relay=local, delay=0.63, delays=0.57/0.03/0/0.03, dsn=2.0.0, status=sent (delivered to mailbox)
    Jan 31 15:44:34 xxxxxxx postfix/local[24707]: E7E343A479: to=, relay=local, delay=0.7, delays=0.57/0.05/0/0.07, dsn=2.0.0, status=sent (delivered to mailbox)

    mail is delivering. but not fetching new mails via thunderbird

    Reply
    • Re-check your Dovecot and Postfix configuration and the location of your emails. Check your ‘mail_location’ and check if the email is stored there.

      Thanks.

      Reply
  22. sir plz help me to fetch email via thunderbird. postfix shows that mail delivered to mailbox. postconf -n and dovecot.conf are pasted below. i can’t findout anything wrong…

    postconf -n
    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
    html_directory = no
    inet_interfaces = all
    inet_protocols = ipv4
    mail_owner = postfix
    mailq_path = /usr/bin/mailq.postfix
    manpage_directory = /usr/share/man
    mydestination = $myhostname, localhost.$mydomain, localhost
    newaliases_path = /usr/bin/newaliases.postfix
    queue_directory = /var/spool/postfix
    readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
    relay_domains = *
    sample_directory = /usr/share/doc/postfix-2.6.6/samples
    sendmail_path = /usr/sbin/sendmail.postfix
    setgid_group = postdrop
    smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
    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_tls_cert_file = /etc/pki/tls/certs/plusmail.in.crt
    smtpd_tls_key_file = /etc/pki/tls/private/plusmail.in.key
    smtpd_tls_loglevel = 3
    smtpd_tls_received_header = yes
    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/gmail_aliases
    virtual_gid_maps = static:2222
    virtual_mailbox_base = /var/gmail
    virtual_mailbox_domains = hash:/etc/postfix/gmail_domains
    virtual_mailbox_maps = hash:/etc/postfix/gmail_mailbox
    virtual_minimum_uid = 2222
    virtual_transport = virtual
    virtual_uid_maps = static:2222

    dovecot conf

    listen = *
    ssl = yes
    ssl_cert = </etc/pki/tls/certs/plusmail.in.crt
    ssl_key = </etc/pki/tls/private/plusmail.in.key

    protocols = imap lmtp pop3
    disable_plaintext_auth = no
    auth_mechanisms = plain login
    mail_access_groups = gmail
    default_login_user = gmail
    first_valid_uid = 2222
    first_valid_gid = 2222
    #mail_location = maildir:~/Maildir
    mail_location = maildir:/var/gmail/%d/%n
    #mail_location=mbox:/mail:INBOX=/var/gmail/%d/%n

    passdb {
    driver = passwd-file
    args = scheme=SHA1 /etc/dovecot/passwd
    }
    userdb {
    driver = static
    args = uid=2222 gid=2222 home=/var/gmail/%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 = gmail
    }

    Reply
  23. Great tutorial. Probably the best anyone can find for setting up email server on the web. Small error on your part. You have left out `vim /etc/postfix/vmail_domains` and `postmap /etc/postfix/vmail_domains` command for the section “Add another account” and this is what is causing many people commenting about various issues, and you keep saying they should check their setting .. Please include that to avoid further confusion. Once again, best guide ever.

    Reply
    • Thank you for your kind words Simon.
      We left out the lines you mentioned because we assume that the user following this article has already configured the virtual domains that he needs in the /etc/postfix/vmail_domains file. Of course it goes without saying that a new virtual domain needs to be added along with the email account and alias before postmapping the configuration files.

      Reply
  24. on a bare install of CentOS 7, I struggled for hours with this:

    Nov 20 01:59:36 post dovecot: imap([email protected]): Error: user [email protected]: Initialization failed: Initializing mail storage from mail_location setting failed: mkdir(/var/vmail/xxxx.com/xxxx) failed: Permission denied (euid=2222(vmail) egid=2222(vmail) missing +w perm: /var/vmail, euid is not dir owner)

    The permissions were in fact correct, the users and groups created correctly. I thought to myself, what could happen with permissions here that I don’t understand (I’ve been at this *nix game a while. )

    Turns out, I had to disable SElinux.

    Hope this helps someone.

    Thanks for the great tutorials!

    Reply
    • This tutorial is very very good!!! help me a lot.
      I successfully run the service on Centos 6.5, but when I move on to Centos 6.7 I got the permission denied problem.

      @Mack Allison,
      Thanks your for big help by pointing out the solution of SELinux.
      Disabled SELinux or set it to permissive mode both can fix the problem.

      Thanks to both of you!

      Reply
  25. Great information there, I just had a small issue that mentioned above in the commends, The mail_location must be same in configs. I had to change mail_location = maildir:/var/vmail/%d/%n in file /etc/dovecot/conf.d/10-mail.conf to be able to read messages via thunderbird or any other client.

    Reply
  26. Excellent! Thank you so much – I have tried a number of similar articles and blogs trying to get virtual users and domains setup properly between postfix and dovecot, and yours is the one that filled in the gaps, and at the same time is the simplest!

    BTW, works fine on CentOS 7 too, except change the chkconfig and service commands to systemctl, but fine apart from that.

    Reply
  27. 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 [email protected] com –from [email protected] com

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

    [[email protected] ~]# swaks –to [email protected] com –from [email protected] 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.
    [[email protected] ~]#
    [[email protected]er2 ~]# swaks –to [email protected] com –from [email protected] 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.

    Reply
    • 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.

      Reply
  28. Hi,

    I created 2 email accounts yesterday ([email protected] & [email protected]). 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 ([email protected]) 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

    [[email protected] ~]# swaks –to [email protected] –from [email protected]
    === 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: [email protected]
    -> From: [email protected]
    -> 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!!

    Reply
  29. Hi,

    I created 2 mail accounts ([email protected] & [email protected]), 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?

    Reply
  30. 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

    Reply
  31. 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([email protected]): Error: user [email protected]: 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([email protected]): 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([email protected]): Error: user [email protected]: 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([email protected]): 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([email protected]): Error: user [email protected]: 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([email protected]): 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([email protected]): Error: user [email protected]: 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([email protected]): 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]

    Reply
  32. Hi,

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

    I tried creating virtual email accounts ([email protected])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” [email protected]

    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

    Reply
  33. 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 “[email protected]” 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 [email protected], because it is trying to search the vmailbox where this user doesn’t exist. However we can receive mails from [email protected].

    Also, I can send/receive email from outside domain to [email protected].

    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

    Reply
    • 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.

      Reply
  34. 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 “[email protected]”, other users are using the mail server created using postfix/dovecot. There email accounts are created under virtual_mailboxes file eg “[email protected]” and “[email protected]

    The scenarios which are PASSED :

    mail from : [email protected] mail to : [email protected] WORKING FINE
    mail from : [email protected] mail to : [email protected] WORKING FINE
    mail from : [email protected] mail to : [email protected] WORKING FINE

    The scenario which is FAILING :

    mail from : [email protected] mail to: [email protected] 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!!

    Reply
  35. 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?

    Reply
  36. I wanted to create vmail_domains configuration file as given in the tutorial. However the file was not created instead the following message appeared:

    -bash-4.1# vim /etc/postfix/vmail_domains

    wned by: root dated: Mon Jan 15 23:13:26 2018
    file name: /etc/postfix/vmail_domains
    modified: no
    user name: root host name: mail.biztech-resources.com
    process ID: 5494 (still running)
    While opening file “/etc/postfix/vmail_domains”

    (1) Another program may be editing the same file. If this is the case,
    be careful not to end up with two different instances of the same
    file when making changes. Quit, or continue with caution.
    (2) An edit session for this file crashed.
    If this is the case, use “:recover” or “vim -r /etc/postfix/vmail_domains”
    to recover the changes (see “:help recovery”).
    If you did this already, delete the swap file “/etc/postfix/.vmail_domains.s
    wp”
    to avoid this message.

    Swap file “/etc/postfix/.vmail_domains.swp” already exists!
    [O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:

    The main.cf does not show this configuration file:

    -bash-4.1# ls /etc/postfix
    access main.cf master.cf.original transport
    canonical main.cf.ORIG master.cf.rpmsave virtual
    generic main.cf.rpmsave relocated vmail_mailbox
    header_checks master.cf ssl vmail_mailbox.db

    Similalry create vmail_aliases configuration file also failed.

    I was however successful in creating vmail_mailbox configuration file.

    I have CentOS 6.9 based VPS and Postfix version is 2.6.6

    I am changing configurations of an old Postfix installed on the VPS to match your configurations. Please help me in getting the configuration files created and moving forward.

    Reply
  37. I would only add to your post the fact that I do not believe that you can forward mail from the virtual address so if you ever want your mail to be redirected, you can not use the USPS to do it from that address not can you use the virtual service to do it. You have to notify everybody you receive mail from about your new address.

    Reply
  38. I followed this tutorial for a Debian server. One thing kept it from working, frustrating me for a few hours, shown in /var/log/mail.log :
    Dec 16 01:57:56 lambda postfix/submission/smtpd[818]: warning: SASL: Connect to /var/spool/postfix/private/auth failed: No such file or directory
    Dec 16 01:57:56 lambda postfix/submission/smtpd[818]: fatal: no SASL authentication mechanisms

    Turns out that in /etc/postfix/main.cf the smtpd_sasl_path needs a RELATIVE path! looking into other tutorials I found this is usually used:
    smtpd_sasl_path = private/auth
    together with the dovecot configuration line:
    unix_listener /var/spool/postfix/private/auth {
    The error seems completely random, complaning about a path that certainly exists, but it really requires a relative path. Might be due to postfix running chrooted or something, I haven’t figured this one out yet as to why it needs to be relative, but if this tutorial fails you with this error message, try this approach.

    Reply

Leave a Reply to Johan Cancel reply

To prove you are human please solve the following *