Set up a mail server with PostfixAdmin and MariaDB on CentOS 7

mail server with postfixadmin and mariadb on centos

In this guide, we will explain how to setup and configure a mail server with PostfixAdmin, Postfix, Dovecot, MariaDB and SpamAssasin on a CentOS VPS. PostfixAdmin is a PHP-based web front-end that allows you to manage virtual domains and users for a Postfix mail transport agent. This guide should work on other Linux VPS systems as well but was tested and written for a CentOS 7 VPS.

If you use an Ubuntu VPS, follow our tutorial to set up a mail server with Postfix, Dovecot, Spamassassin, SQLite and PostfixAdmin on an Ubuntu 16.04 VPS

If you want to use SQLite instead of MariaDB, follow our tutorial to set up a mail server with Postfix, Dovecot, Spamassassin, SQLite and PostfixAdmin on a CentoOS 7 VPS

1. Update the system and install necessary packages

yum update && yum install wget nano

2. Create system user

For security reasons, we will create a new system user who will be the owner of all mailboxes.

useradd -r -u 150 -g mail -d /var/vmail -s /sbin/nologin -c "Virtual Mail User" vmail
mkdir -p /var/vmail
chmod -R 770 /var/vmail
chown -R vmail:mail /var/vmail

3. Install MariaDB

MariaDB 5.5 is shipped in the default CentOS 7 repository, to install it just run:

yum install mariadb-server

To start the MariaDB service and enable it to start on boot, execute the following commands:

systemctl start mariadb.service
systemctl enable mariadb.service

Run the following command to secure your MariaDB installation:

mysql_secure_installation

Next, we need to create a database for our postfixadminHQ instance.

mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE postfixadmin;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON postfixadmin.* TO 'postfixadmin'@'localhost' IDENTIFIED BY 'strong_password';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> \q

4. Install PHP and all necessary PHP modules

CentOS 7 ships with PHP version 5.4, to install PHP and necessary modules, run:

yum install php php-mysql php-imap php-mbstring php-common

If you don’t have Apache installed, install it with:

yum install httpd

5. Install PostfixAdmin

The latest version of PostfixAdmin, version 3, supports MySQL/MariaDB, PostgreSQL, and SQLite databases. In this guide, we will use MariaDB.
Download the PostfixAdmin archive from SourceForge and extract it in the /var/www/html/ directory:

wget -q -O - "https://downloads.sourceforge.net/project/postfixadmin/postfixadmin/postfixadmin-3.0.2/postfixadmin-3.0.2.tar.gz" | tar -xzf - -C /var/www/html

Open the mail configuration file and edit the following values:

nano /var/www/html/postfixadmin-3.0.2/config.inc.php
$CONF['configured'] = true;
$CONF['database_type'] = 'mysqli';
$CONF['database_host'] = 'localhost';
$CONF['database_user'] = 'postfixadmin';
$CONF['database_password'] = 'strong_password';
$CONF['database_name'] = 'postfixadmin';

$CONF['domain_path'] = 'NO';
$CONF['domain_in_mailbox'] = 'YES';
chown -R apache: /var/www/html/postfixadmin-3.0.2

To populate the database go to https://Your_IP_Address/postfixadmin-3.0.2/setup.php and you should see something like below:
Testing database connection - OK - mysqli://postfixadmin:xxxxx@localhost/postfixadmin
Everything seems fine... attempting to create/update database structure

Create a new admin user:

bash /var/www/html/postfixadmin-3.0.2/scripts/postfixadmin-cli admin add admin@your_domain_name.com --password strong_password22 --password2 strong_password22 --superadmin 1 --active 1

6. Install and configure postfix

To install postfix run the command bellow:

yum install postfix

Once the installation is completed, we need to create configuration files:

mkdir -p /etc/postfix/sql/
nano /etc/postfix/sql/mysql_virtual_alias_domain_catchall_maps.cf
user = postfixadmin
password = strong_password
hosts = localhost
dbname = postfixadmin
query  = SELECT goto FROM alias,alias_domain WHERE alias_domain.alias_domain = '%d' and alias.address = CONCAT('@', alias_domain.target_domain) AND alias.active = 1 AND alias_domain.active='1'
nano /etc/postfix/sql/mysql_virtual_alias_domain_mailbox_maps.cf
user = postfixadmin
password = strong_password
hosts = localhost
dbname = postfixadmin
query = SELECT maildir FROM mailbox,alias_domain WHERE alias_domain.alias_domain = '%d' and mailbox.username = CONCAT('%u', '@', alias_domain.target_domain) AND mailbox.active = 1 AND alias_domain.active='1'
nano /etc/postfix/sql/mysql_virtual_alias_domain_maps.cf
user = postfixadmin
password = strong_password
hosts = localhost
dbname = postfixadmin
query = SELECT goto FROM alias,alias_domain WHERE alias_domain.alias_domain = '%d' and alias.address = CONCAT('%u', '@', alias_domain.target_domain) AND alias.active = 1 AND alias_domain.active='1'
nano /etc/postfix/sql/mysql_virtual_alias_maps.cf
user = postfixadmin
password = strong_password
hosts = localhost
dbname = postfixadmin
query = SELECT goto FROM alias WHERE address='%s' AND active = '1'
#expansion_limit = 100
nano /etc/postfix/sql/mysql_virtual_domains_maps.cf
user = postfixadmin
password = strong_password
hosts = localhost
dbname = postfixadmin
query          = SELECT domain FROM domain WHERE domain='%s' AND active = '1'
#query          = SELECT domain FROM domain WHERE domain='%s'
#optional query to use when relaying for backup MX
#query           = SELECT domain FROM domain WHERE domain='%s' AND backupmx = '0' AND active = '1'
#expansion_limit = 100
nano /etc/postfix/sql/mysql_virtual_mailbox_limit_maps.cf
user = postfixadmin
password = strong_password
hosts = localhost
dbname = postfixadmin
query = SELECT quota FROM mailbox WHERE username='%s' AND active = '1'
nano /etc/postfix/sql/mysql_virtual_mailbox_maps.cf
user = postfixadmin
password = strong_password
hosts = localhost
dbname = postfixadmin
query           = SELECT maildir FROM mailbox WHERE username='%s' AND active = '1'
#expansion_limit = 100

[ecko_alert color=”blue”]Stuck somewhere? Get a VPS from us and we’ll do all of this for you, free of charge! We’ll completely set up and configure a mail server for you. [/ecko_alert]

Edit the main.cf file:

postconf -e "myhostname = $(hostname -f)"
 
postconf -e "virtual_mailbox_domains = proxy:mysql:/etc/postfix/sql/mysql_virtual_domains_maps.cf"
postconf -e "virtual_alias_maps = proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_maps.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_maps.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_catchall_maps.cf"
postconf -e "virtual_mailbox_maps = proxy:mysql:/etc/postfix/sql/mysql_virtual_mailbox_maps.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_mailbox_maps.cf"
 
postconf -e "smtpd_tls_cert_file = /etc/pki/tls/certs/localhost.crt"
postconf -e "smtpd_tls_key_file = /etc/pki/tls/private/localhost.key"
postconf -e "smtpd_use_tls = yes"
postconf -e "smtpd_tls_auth_only = yes"
 
postconf -e "smtpd_sasl_type = dovecot"
postconf -e "smtpd_sasl_path = private/auth"
postconf -e "smtpd_sasl_auth_enable = yes"
postconf -e "smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination"
 
postconf -e "mydestination = localhost"
postconf -e "mynetworks = 127.0.0.0/8"
postconf -e "inet_protocols = ipv4"
postconf -e "inet_interfaces = all"

postconf -e "virtual_transport = lmtp:unix:private/dovecot-lmtp"

Open the master.cf file, find submission inet n and smtps inet n sections and edit as follows:

nano /etc/postfix/master.cf
submission inet n       -       n       -       -       smtpd
  -o syslog_name=postfix/submission
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_reject_unlisted_recipient=no
#  -o smtpd_client_restrictions=$mua_client_restrictions
#  -o smtpd_helo_restrictions=$mua_helo_restrictions
#  -o smtpd_sender_restrictions=$mua_sender_restrictions
#  -o smtpd_recipient_restrictions=
  -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
  -o milter_macro_daemon_name=ORIGINATING
smtps     inet  n       -       n       -       -       smtpd
  -o syslog_name=postfix/smtps
#  -o smtpd_tls_wrappermode=yes
  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_reject_unlisted_recipient=no
#  -o smtpd_client_restrictions=$mua_client_restrictions
#  -o smtpd_helo_restrictions=$mua_helo_restrictions
#  -o smtpd_sender_restrictions=$mua_sender_restrictions
#  -o smtpd_recipient_restrictions=
  -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
  -o milter_macro_daemon_name=ORIGINATING

Enable the postfix service

systemctl enable postfix
systemctl restart postfix

7. Install and Configure Dovecot

Install dovecot with MySQL support using the command bellow:

yum install dovecot dovecot-mysql

Open the /etc/dovecot/conf.d/10-mail.conf file and change the following values:

nano /etc/dovecot/conf.d/10-mail.conf
mail_location = maildir:/var/vmail/%d/%n
mail_privileged_group = mail
mail_uid = vmail
mail_gid = mail
first_valid_uid = 150
last_valid_uid = 150

Open the /etc/dovecot/conf.d/10-auth.conf file and change the following values:

nano /etc/dovecot/conf.d/10-auth.conf
auth_mechanisms = plain login
#!include auth-system.conf.ext
!include auth-sql.conf.ext

Create a new dovecot-sql.conf.ext file:

nano /etc/dovecot/dovecot-sql.conf.ext
driver = mysql
connect = host=localhost dbname=postfixadmin user=postfixadmin password=strong_password
default_pass_scheme = MD5-CRYPT
password_query = SELECT username as user, password, '/var/vmail/%d/%n' as userdb_home, 'maildir:/var/vmail/%d/%n' as userdb_mail, 150 as userdb_uid, 8 as userdb_gid FROM mailbox WHERE username = '%u' AND active = '1'
user_query = SELECT '/var/vmail/%d/%u' as home, 'maildir:/var/vmail/%d/%u' as mail, 150 AS uid, 8 AS gid, concat('dirsize:storage=',  quota) AS quota FROM mailbox WHERE username = '%u' AND active = '1'

In the /etc/dovecot/conf.d/10-ssl.conf file enable SSL support:

ssl = yes

Open the /etc/dovecot/conf.d/15-lda.conf file and set the postmaster_address email address.

postmaster_address = postmaster@your_domain_name.com

Open the /etc/dovecot/conf.d/10-master.conf file, find the service lmtp section and change it to:

service lmtp {
  unix_listener /var/spool/postfix/private/dovecot-lmtp {
    mode = 0600
    user = postfix
    group = postfix
  }
}

find the service auth section and change it to:

service auth {
  unix_listener /var/spool/postfix/private/auth {
    mode = 0666
    user = postfix
    group = postfix
  }
  unix_listener auth-userdb {
    mode = 0600
    user = vmail
    #group = vmail
  }
  user = dovecot
}

Change the service auth-worker section to the following:

service auth-worker {
  user = vmail
}

Set the permissions:

chown -R vmail:dovecot /etc/dovecot
chmod -R o-rwx /etc/dovecot

Enable and restart the dovecot service

systemctl enable dovecot 
systemctl restart dovecot 

8. Install and configure Spamassassin

Install spamassassin using the command bellow:

yum install spamassassin

Create a spamassassin system user:

groupadd spamd
useradd -g spamd -s /bin/false -d /var/log/spamassassin spamd
chown spamd:spamd /var/log/spamassassin

9. Configure Postfix to use SpamAssassin

Open the master.cf file and edit as follows:

nano /etc/postfix/master.cf

change

smtp      inet  n       -       n       -       -       smtpd

with

smtp      inet  n       -       n       -       -       smtpd -o content_filter=spamassassin

add the following line at the end of the file:

spamassassin unix - n n - - pipe flags=R user=spamd argv=/usr/bin/spamc -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}

Enable and restart the spamassassin service

systemctl enable spamassassin 
systemctl restart spamassassin 

Restart the postfix service

systemctl restart postfix

If everything is set up correctly now you should be able to log in to your PostfixAdmin backend by going to http://Your_IP_Address/postfixadmin-3.0.2.2 and create your first virtual domain and mailbox.


Of course, you don’t have to Set up a mail server with PostfixAdmin and MariaDB on CentOS 7,  if you use one of our Mail Server Hosting services, in which case you can simply ask our expert Linux admins to set up a mail server for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post, on how to Set up a mail server with PostfixAdmin and MariaDB on CentOS 7,  please share it with your friends on the social networks using the buttons below or simply leave a comment in the Comments Section below. Thanks.

101 thoughts on “Set up a mail server with PostfixAdmin and MariaDB on CentOS 7”

  1. I followed your tutorial but i get the following error in logs.

    private/dovecot-lmtp]: No such file or directory)

    Reply
  2. I Have followed all the step but is give this error on “populating the database”

    Postfix Admin Setup Checker

    Running software:

    PHP version 5.4.16
    Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips PHP/5.4.16
    Checking for dependencies:

    Magic Quotes: Disabled – OK
    Depends on: presence config.inc.php – OK
    Checking $CONF[‘configured’] – OK
    Smarty template compile directory is writable – OK
    Error: There is no database support in your PHP setup
    To install MySQL 3.23 or 4.0 support on FreeBSD:
    % cd /usr/ports/databases/php5-mysql/
    % make clean install
    – or with portupgrade –
    % portinstall php5-mysql
    To install MySQL 4.1 support on FreeBSD:
    % cd /usr/ports/databases/php5-mysqli/
    % make clean install
    – or with portupgrade –
    % portinstall php5-mysqli
    To install PostgreSQL support on FreeBSD:
    % cd /usr/ports/databases/php5-pgsql/
    % make clean install
    – or with portupgrade –
    % portinstall php5-pgsql
    Error: Can’t connect to database
    Please edit the $CONF[‘database_*’] parameters in config.inc.php.
    DEBUG INFORMATION:
    MySQL 4.1 functions not available! (php5-mysqli installed?)
    database_type = ‘mysqli’ in config.inc.php, are you using a different database?

    Depends on: session – OK
    Depends on: pcre – OK
    Depends on: multibyte string – OK
    Warning: Depends on: IMAP functions – NOT FOUND
    To install IMAP support, install php5-imap
    Without IMAP support, you won’t be able to create subfolders when creating mailboxes.

    Reply
  3. when i add these lines to main.cf then service want start please help me

    postconf -e “myhostname = $(hostname -f)”

    postconf -e “virtual_mailbox_domains = proxy:mysql:/etc/postfix/sql/mysql_virtual_domains_maps.cf”
    postconf -e “virtual_alias_maps = proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_maps.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_maps.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_catchall_maps.cf”
    postconf -e “virtual_mailbox_maps = proxy:mysql:/etc/postfix/sql/mysql_virtual_mailbox_maps.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_mailbox_maps.cf”

    postconf -e “smtpd_tls_cert_file = /etc/pki/tls/certs/localhost.crt”
    postconf -e “smtpd_tls_key_file = /etc/pki/tls/private/localhost.key”
    postconf -e “smtpd_use_tls = yes”
    postconf -e “smtpd_tls_auth_only = yes”

    postconf -e “smtpd_sasl_type = dovecot”
    postconf -e “smtpd_sasl_path = private/auth”
    postconf -e “smtpd_sasl_auth_enable = yes”
    postconf -e “smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination”

    postconf -e “mydestination = localhost”
    postconf -e “mynetworks = 127.0.0.0/8”
    postconf -e “inet_protocols = ipv4”
    postconf -e “inet_interfaces = all”

    postconf -e “virtual_transport = lmtp:unix:private/dovecot-lmtp”

    Reply
  4. where/when you generate these certs?

    postconf -e “smtpd_tls_cert_file = /etc/pki/tls/certs/localhost.crt”
    postconf -e “smtpd_tls_key_file = /etc/pki/tls/private/localhost.key”

    Reply
  5. This email address already exists please choose a different one. Gives this error when creating the alias. Please can you guide the solution.

    Reply
  6. Basically i want to configure email forwarding for the existing user to different email. Like in Exchange Server

    Reply
      • Yes i am sure configurations are ok.
        And this is the error below:

        This email address already exists, please choose a different one!

        Reply
    • Postfixadmin does not provide such an option.
      You can try to do it manually –
      https://serverfault.com/questions/522755/is-it-possible-to-block-a-certain-email-adress-from-sending-email-anywhere-other

      Reply
  7. Please advise what protocols I need to set for email client
    getting smtp error – I have configured for thunderbird 587
    Imap I have configured 143

    Reply
  8. please I have a issues 0.03/0/0, dsn=4.4.1, status=deferred (connect to ns1.test66.pv[private/dovecot-lmtp]: No such file or directory

    Reply
  9. Yea, I can see where they are having problems, I got to dovecot install 10-mail.conf
    mail_location = maildir:/var/vmail/%d/%n
    which doesn’t match your postfixadmin config

    $CONF[‘domain_path’] = ‘NO’;
    $CONF[‘domain_in_mailbox’] = ‘YES’;

    Reply
  10. Hi,
    thanks for this wonderful guide!
    I’ve followed step by step closely, and my mail server is setup, except for the spamassassin part… when I enable the filter, I can’t recive email anymore from the external world, senders receive a reply back saying message undelivered:
    Final-Recipient: rfc822; user@mydomain.tld
    Original-Recipient: rfc822;user@mydomain.tld
    Action: failed
    Status: 5.3.0
    Diagnostic-Code: x-unix; service unavailable

    If I remove the -o content_filter=spamassassin and spamassassin unix – n n – – pipe flags=R user=spamd argv=/usr/bin/spamc -e /usr/sbin/sendmail -oi -f ${sender} ${recipient} at the end of the file, mailflow works perfectly (even alias).
    What can be the issue here?
    PS: in the rejected email if I look at the rejected message I can se the [SPAM] in the email subject…so something is happening with spamassassin engine that refuse email without delivering them.

    Thanks for any help you would provide and for your time.
    Cico.

    Reply
  11. Hello,

    I follow the steps & everything is fine, when I tried to login to the Postfix Admin using the admin email & password it keeps getting back to the same form.
    When i entered a wrong password, it did give password error message!

    Will you help me please.

    best regards,

    Reply
  12. Hi Admin,
    I tried doing all the methods as mentioned.But I am getting an error like shown below when I tried to create another admin user:

    bash /var/www/html/postfixadmin-3.0.2/scripts/postfixadmin-cli admin add admin@your_domain_name.com –password strong_password22 –password2 strong_password22 –superadmin 1 –active 1

    DEBUG INFORMATION:Connect: Access denied for user ‘postfixadmin’@’localhost’ (using password: YES)

    Please help me.

    Reply
        • Access denied for user ‘postfixadmin’@’localhost’ (using password: YES)

          means the password you are using for Postfixadmin to connect to the MySQL database is not correct. Make sure you are using the correct password for the MySQL database user.

          Reply
          • Hi Sir,
            I could configure the mail server as mentioned in the tutorial.But can you please help me in creating the virtual domain and mailbox??I could not do it and do we have to do any modification for that in the above tutorial ??
            please suggest any blog too which contains these information regarding creating virtual domain and mailbox.

  13. Good morning, please could you help me, I’m from Bolivia.
    When I want to create a mailbox it does not allow me because it shows a message: “Your password must contain at least 2 digit (s).” in postfixadmin. you know why ?

    Reply
  14. Hard to believe this works for everyone considering the ‘8 as userdb_gid’ in /etc/dovecot/dovecot-sql.conf.ext I think it should be 89 the postfix GID. What am I missing?

    Reply
  15. Very good howto, thanks a lot! used with postfixadmin-3.1 and centos7@20180126.

    httpd/posfixadmin needs selinux to be turned off to work.

    # setenforce 0

    Reply
  16. Do you have a control panel on your server?

    Please follow the instructions closely. Check your /etc/dovecot/conf.d/10-mail.conf Dovecot configuration file and add/modify the settings as explained in the tutorial:

    mail_location = maildir:/var/vmail/%d/%n
    mail_privileged_group = mail
    mail_uid = vmail
    mail_gid = mail
    first_valid_uid = 150
    last_valid_uid = 150

    Reply
  17. Hi and thanks for the tutorial. When I create the vmail user, my selinux CentOS 7 system is adding it to the mail group which has a gid of 12 :-

    [root]# id vmail
    uid=150(vmail) gid=12(mail) groups=12(mail)

    Will this effect any of your scripts e.g. dovecot-sql.conf.ext

    Thanks

    Reply
  18. Hello,

    I’m use plugins postfixadmin for squirrelmail, but when I login denied

    dovecot: imap(xxxx@xxxx.com): Error: opendir(/var/vmail/xxxx.com/xxxx@xxxxx.com) failed: Permission denied (euid=150(vmail) egid=8(mem) missing +r perm: /var/vmail/xxxx.com/xxx@xxxxxcom, UNIX perms appear ok (ACL/MAC wrong?))

    Please help me
    thank you

    Reply
  19. I did add some lines as mentioned in the topic
    to main.cf then my postfix won’t work anymore.

    Jul 5 02:43:55 db1 aliasesdb: /usr/sbin/postconf: fatal: /etc/postfix/main.cf, line 680-681: missing ‘=’ after attribute name: “postconf -e “myhostname = $(hostname -f)””
    Jul 5 02:43:56 db1 aliasesdb: newaliases: fatal: /etc/postfix/main.cf, line 680-681: missing ‘=’ after attribute name: “postconf -e “myhostname = $(hostname -f)””
    Jul 5 02:43:57 db1 systemd: postfix.service: control process exited, code=exited status=1
    Jul 5 02:43:57 db1 systemd: Failed to start Postfix Mail Transport Agent.
    Jul 5 02:43:57 db1 systemd: Unit postfix.service entered failed state.
    Jul 5 02:43:57 db1 systemd: postfix.service failed.

    Reply
    • You need to run :
      postconf -e “myhostname = $(hostname -f)”
      postconf -e “virtual_mailbox_domains = proxy:mysql:/etc/postfix/sql/mysql_virtual_domains_maps.cf”
      and so on, not paste the commands in the main.cf file.

      Reply
  20. any idea? thank in advance.

    type=AVC msg=audit(1530909442.543:4021): avc: denied { write } for pid=7232 comm=”lmtp” name=”vmail” dev=”vda1″ ino=642486 scontext=system_u:system_r:dovecot_t:s0 tcontext=unconfined_u:object_r:var_t:s0 tclass=dir permissive=0

    drwxrwx—. 2 vmail mail 4096 permission for the mail folder.

    failed: Permission denied (euid=150(vmail) egid=8(mem) UNIX perms appear ok (ACL/MAC wrong?))

    Reply
  21. Hi,

    I have followed all the steps. But unable to send email outside the domain. Internal emails working fine.

    Reply
    • If you followed all the instructions provided in this tutorial there should be no issues with sending out your emails.
      Please check if there is anything in the mail logs regarding this problem.

      Reply
  22. i got the following error please help me

    postfix/smtpd[3028]: NOQUEUE: reject: RCPT from rashid.getyourdomain.org[195.201.76.125]: 554 5.7.1 : Relay access denied; from= to= proto=ESMTP helo=

    Reply
    • This error commonly occurs when the sender doesn’t authenticate properly to the outgoing mail server before sending the email. Check your email client settings and make sure you can authenticate successfully before sending an email.

      Reply
  23. this issue is solved when i added my ip address in mynetworks on postfix configuration.

    but i want to relay all networks.

    please help me

    Reply
  24. Hello administrator, I have a problem, my server is like an open relay, when I connect by telnet to port 25 it is possible to send emails. I would like only authenticated users to send emails, how can I do it? Please, could you help me?

    Reply
      • That’s weird. I follow through and through the tutorial and it gave me ZERO errors. However, I tried to send out an email to my gmail account and got nothing. How would I go about troubleshooting this? Should I try to look at the logs (to which I don’t know their location)? For reference, I’m running with an internal DNS with forwarding, so maybe the problem is there? Still would not make sense since the GMail record is being resolved.
        Thank you so much for replying and I hope you can help.

        Reply
        • Yes, you should definitely look into the log files and see what happens when you try to send email. The log file is usually called /var/log/maillog or /var/log/mail.

          Reply
  25. OK, I follow through but I get these errors in the log:
    postfix/sendmail[1424]: fatal: usage: sendmail [options]
    postfix/pipe[1425]: 7092DCC2C7C: to=, relay=spamassassin, delay=62160, delays=62157/0.07/0/2.5, dsn=4.3.0, status=deferred (temporary failure. Command output: sendmail: option requires an argument — ‘f’ sendmail: option requires an argument — ‘f’ sendmail: fatal: usage: sendmail [options] )
    spamc[1424]: connect to spamd on 127.0.0.1 failed, retrying (#2 of 3): Connection refused
    spamc[1426]: connect to spamd on ::1 failed, retrying (#3 of 3): Connection refused

    Reply
    • Are you sending the email through the command line or via script? When using -f as option with sendmail you need to specify the envelope sender address as argument. As for the other error message, check if spamd is running.

      Reply
  26. Hi there,

    thanks for this great tutorial. But for the moment I have 2 problems:
    a) when I want to send a mail via postfix.admin I receiv in the maillog a “warning: non-SMTP command from localhost[127.0.0.1]: To: ”
    b) when I create a new Mailboxuser the folderstructur under /var/vmail ist not created

    Any Ideas, where I can search for?

    Kind regards
    Oliver

    Reply
    • a) This is a warning message and it notifies you that non-SMTP command is being sent. You can do a research on Google for more information about how to fix this.
      b) The directories should be created once you log in via IMAP. If they are not created, check this file permissions and if there is a problem you can fix them using:

      chmod -R 770 /var/vmail
      chown -R vmail:mail /var/vmail
      Reply
  27. Hi,
    This tutorial was very helpful for me. But I have a question about modyfing this configuration for use in multidomain/multiIP environment? Standard configuration of postfix multiinstance will be correct? Could You show me some tips about it?

    Reply
  28. with this tutorial is it possible to send emails with SMTP authentication ?.
    I can not, even when I send only internally.

    Dec 4 20:21:19 centos-transacional postfix/qmgr[12996]: 3333620474D6: from=, size=779, nrcpt=1 (queue active)
    Dec 4 20:21:19 centos-transacional postfix/lmtp[13666]: 3333620474D6: to=, relay=none, delay=357, delays=357/0.07/0/0, dsn=4.4.1, status=deferred (connect to centos-transacional.automate.center[private/dovecot-lmtp]: Connection refused)

    Reply
  29. Hi, thanks for sharing your knowledge, please could you tell me how can I do the mailbox quota warning?, for example when is over 95 %.

    Reply
  30. Hi, this is a great tutorial. How i can integrate Sophos puremessage antispam in to this server or in another server???

    Reply
  31. Hi, this is really a great tutorial. I have only the problem about mailbox quota. When i make a new mailbox, by postfixadmin, i usually set mailbox quotas. The value is wrote in to the postfixadmin database correctly, If I send an email more big than quota, i recive that mail without errors. Why??

    Reply
  32. Hello,
    Could You tell me, what i have to do, to automatic creation of directory structure during account create?

    Reply
    • Hi Thomas,

      If you are asking about the email accounts, PostfixAdmin will automatically create all necessary files and directories.

      Reply
  33. Greatings,

    All seems right now with my server, but i have a problem of authentication…
    maybe a misconfiguration of evolution ?
    please let me know required configuration for imaps, pop3 tls, and smtps
    i use the user francesco qith the password defined for my mail address.

    Thank you very much anyway for this tutorial,
    Regards,
    Franck

    Reply
  34. Thank you for the post. This is has really helped me in setting up our mailing environment. The only issue we are facing is that we are unable to authenticate through a mail client be it squirrel mail or thunderbird. Is there any additional configuration steps for integrating the login credentials of squirrel mails with the virtual users created in Postfixadmin? Also, will the defaul ssl cert and key file provided with Dovecot work or do we need to change it with our own ssl files? Your help will be highly appreciated.

    Reply
  35. Hi, thanks for sharing your knowledge, please could you tell me how can I do the mailbox quota warning?, for example when is over 95 %.

    Reply
  36. The set up was flawless till installation and postfix, I was facing trouble while configuring dovecot using MySQL, the command isn’t working for me.

    Reply
    • Please follow the instructions carefully. If you have a question about a particular command, feel free to leave a comment about.

      Reply
  37. hi
    This is my error :
    dovecot : imap (email ):Error: Mail access for users with UID 150 not permitted (see first_valid_uid in config file, uid from userdb lookup).

    Error: Invalid user settings. Refer to server log for more information.

    whats problem ?

    Reply
  38. i followed your script for my postfixadmin installation but i am facing this error.

    fatal: /etc/postfix/main.cf, line 683-684: missing ‘=’ after attribute name: “postconf -e “myhostname=$(hostname -f)””

    Reply
    • Please double check if you ran all the commands in the guide. In the part “Edit the main.cf file:” you shouldn’t edit the file with the code, you should run the code..

      Reply

Leave a Comment