Setup Vacation on Postfixadmin 3.2 Centos 7.x

This year we set up a new server with Postfixadmin 3.2 and I recently also had to set the vacation module.
I want to outline how I’ve solved the problem that appears on setup.

1. Install perl library dependancies:

yum install perl-Email-Valid perl-Email-Sender perl-Email-Simple perl-Test-Email perl-Try-Tiny perl-MIME-Charset perl-MIME-EncWords perl-Log-Log4perl perl-Log-Dispatch perl-Test-mysqld

For Debian:

apt-get installlibmail-sender-perl
libdbd-mysql-perl libemail-valid-perl libmime-perl liblog-log4perl-perl
liblog-dispatch-perl libgetopt-argvfile-perl libmime-charset-perl

2.  Add user and group, crete folder.
groupadd -r -g 65501 vacation
useradd -r -u 65501 -g vacation -d /var/spool/vacation -s /sbin/nologin vacation

mkdir /var/spool/vacation
cp /var/www/html/postfixadmin/VIRTUAL_VACATION/ /var/spool/vacation
chown -R vacation:vacation /var/spool/vacation

chmod -R 750 /var/spool/vacation/

3. Setup script.

vim /var/spool/vacation/

our $db_type = ‘mysql’;
our $db_username = ‘postfix’;
our $db_password = ‘yourdbpasswd’;
our $db_name = ‘postfix’;

our $vacation_domain = ‘’;

close file with :wq

Setup config.local.php
vim /var/www/html/postfixadmin/config.local.php

$CONF[‘vacation’] = ‘YES’;
$CONF[‘vacation_domain’] = ‘’;

4. Config vacation in postfix

vim /etc/postfix/


vacation unix – n n – – pipe
flags=Rq user=vacation argv=/var/spool/vacation/ -f ${sender} — ${recipient}

( do not forget to add some space in front  “flags=….. ” )

Make sure you have this line in /etc/postfix/

transport_maps = hash:/etc/postfix/transport

vim /etc/postfix/transport    vacation:

Save file and close. After this:

postmap /etc/postfix/transport

Restart Postfix

systemctl restart postfix.service.

Follow these steps if you get an error in logs like this:

Aug 20 14:25:01 mail postfix/pipe[24086]: 43AF03E0B63: to=<>, orig_to=<>, relay=vacation, delay=2, delays=1.4/0.01/0/0.56, dsn=5.3.0, status
=bounced (Command died with status 255: “/var/spool/vacation/”. Command output: Attribute (ssl) does not pass the type constraint because: Validation failed for ‘Bool’ with value “starttls” at
constructor Email::Sender::Transport::SMTP::new (defined at /usr/share/perl5/vendor_perl/Email/Sender/Transport/ line 200) line 98, <STDIN> line 38. Email::Sender::Transport::SMTP::new(‘Email::Sen
der::Transport::SMTP’, ‘HASH(0x433e128)’) called at /var/spool/vacation/ line 474 main::send_vacation_email(‘’, ‘’, ‘’, ‘<b2f160c>’, 456, 0) called at /var/spool/vacation/ line 657 )


vim /var/spool/vacation/

and change

our $smtp_ssl = ‘ssl’
our $smtp_ssl = ‘0’

How to upgrade Postfixadmin from old version to new version.

Hello, we need now to upgrade from postfixadmin-2.3.5 to postfixadmin-3.0.2.

This document describes upgrading from an older PostfixAdmin version >= v1.5x on Centos Linux.

1: Backup the Database and file!

[root@mail html]# cp -p -R postfixadmin-2.3.5 postfixadmin-2.3.5-bkp
[root@mail html]# mysqldump -uroot -p –routines –single-transaction postfix > /root/work/postfix-sqldump.sql

2: Go to html directory

[root@mail html]# cd /var/www/html/

Get new archive

[root@mail html]# wget

Unarchive new Postfix Admin

[root@mail html]# tar -zxvf postfixadmin-3.0.2.tar.gz

3: Change permissions

[root@mail html]# cd /var/www/html/postfixadmin-3.0.2
[root@mail postfixadmin-3.0.2]# find -type f -print0 | xargs -0 chmod 640
[root@mail postfixadmin-3.0.2]# find -type f -print0 | xargs -0 chown root:apache
[root@mail postfixadmin-3.0.2]# chown -R apache. templates_c/

Since version 3.0 we use smarty templates. That means the templates_c directory needs to be writeable for your webserver ( create if do not exist ).

[root@mail postfixadmin-3.2]# mkdir templates_c && chmod 750 templates_c && chown -R apache. templates_c

( if your Apache runs as user “apache” )

4: Configure

Check the file. There you can specify settings that are relevant to your setup.

Comparing with your previous using “diff” might save you some time.

You can use a config.local.php file to contain your local settings. These will override any defined in – and save some time when upgrading to a new version of PostfixAdmin 😉

5: Run setup.php

Go to you apache vhost and change the path.

[root@mail html]# vim /etc/httpd/conf/httpd.conf

ServerPath /postfixadmin-3.0.2
DocumentRoot /var/www/html/postfixadmin-3.0.2
CustomLog /var/log/httpd/postfixadmin_access.log combined
ErrorLog /var/log/httpd/postfixadmin_error.log

Restart apache service:
[root@mail html]# service httpd restart

Now we run setup.php
I open a new tab in my browser and type

If it is ok you should see like this:

Postfix Admin Setup Checker

Running software:

  • PHP version 5.3.3
  • Apache

Checking for dependencies:

  • Magic Quotes: Disabled – OK
  • Depends on: presence – OK
  • Checking $CONF[‘configured’] – OK
  • Smarty template compile directory is writable – OK
  • Depends on: MySQL 3.23, 4.0 – OK
  • Depends on: MySQL 4.1 – OK
    (change the database_type to ‘mysqli’ in if you want to use MySQL)
  • Depends on: SQLite – OK
    (change the database_type to ‘sqlite’ in if you want to use SQLite)
  • Testing database connection – OK – mysql://postfix:xxxxx@localhost/postfix
  • Depends on: session – OK
  • Depends on: pcre – OK
  • Depends on: multibyte string – OK
  • Depends on: IMAP functions – OK

Everything seems fine… attempting to create/update database structure

Database is up to date

Since version 2.3, PostfixAdmin supports alias domains ($CONF[‘alias_domain’]).
If you want to use them, you have to add some queries to your postfix config – see POSTFIX_CONF for details.

This is all that is needed.

Configure mail server on Centos 7 with Postfix, Dovecot, Apache, postfixadmin and Roundcube.

We starting from Centos 7 Infrastructure Server with Mail Server from Installer.
We have now:

1 – We have public IP
2 – Revers DNS for this IP
3 – Domain already bought.

Step 0. Preparing with minimal aplication to install:

yum -y install wget whois nc vim gpm ppp rp-pppoe dialog logwatch telnet nmap mutt
yum -y install epel-release
yum -y update
yum -y install perl-MailTools perl-MIME-EncWords perl-Email-Valid perl-Test-Pod dovecot dovecot-mysql  dovecot-pigeonhole  perl-Mail-Sender perl-Log-Log4perl imapsync offlineimap amavisd-new clamav perl-Razor-Agent mariadb-server opendkim vim wget crypto-utils mod_ssl.x86_64 php php-mysql php-fpm  clamav-update php-imap.x86_64 NetworkManager-tui mailx lrzip lzop lz4 arj  unzoo cabextract p7zip fail2ban php-mcrypt.x86_64
systemctl stop rpcbind
systemctl disable rpcbind

Step 1.  Setup your hostname server.
hostnamectl set-hostname
Edit you /etc/hosts to look like this
[root@mail ~]# cat /etc/hosts localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 mail

Step 2.  Test postfix local delivery
We create 2 users for local delivery test.
useradd -d /home/john -M -N -s /sbin/nologin john
useradd -d /home/mark -M -N -s /sbin/nologin mark

Now we will send a local mail.
echo Hello | mail -s test john@localhost
and will check if mail has been delivered
tail -f /var/log/maillog
Oct 21 14:55:58 localhost postfix/local[2916]: 770201440486: to=<>, orig_to=<john@localhost>, relay=local, delay=0.19, delays=0.13/0.02/0/0.04, dsn=2.0.0, status=sent (delivered to mailbox)

if works go to next step

Step 3. Setup MariaDB.
Config next /etc/my.cnf.d/server.cnf file like this:
# this is read by the standalone daemon and embedded servers
innodb_file_format = Barracuda
# this is only for the mysqld standalone daemon

Enable mariadb service
systemctl enable mariadb.service
Start mariadb database server
systemctl start mariadb.service
Secure mariadb installation

Step 4. Configure Clam Antivirus

We need to configure how clam refreshes his database
vim /etc/sysconfig/freshclam

comment or remove last line
#  FRESHCLAM_DELAY=disabled-warn    # REMOVE ME

we will make a edit clamav config file
vim /etc/freshclam.conf

comment or remove line with words   “example”.

and finally update your viruses database.

Step 5. Configure basic settings in spamassasin

Enable spamassasin service

systemctl start spamassassin.service
systemctl status spamassassin.service
systemctl enable spamassassin.service
update spamassasin definitions
 Step 6. Integrate spamassasin and clamav with amavisd.
First install some app:
yum -y install clamav clamav-devel clamav-server clamd
We need to provide some config files.
cp /usr/share/doc/clamav-server-0.99.2/clamd.sysconfig /etc/sysconfig/clamd.amavisd
We need to adapt config file to our actual configuration.
vim /etc/sysconfig/clamd.amavisd

and add to last line

We will create a couple of new files
vim /etc/tmpfiles.d/clamd.amavisd.conf
add this content
d /var/run/clamd.amavisd 0755 amavis amavis -
Edit next file
vim /usr/lib/systemd/system/clamd@.service
with this content
Description = clamd scanner (%i) daemon
After =
Type = simple
ExecStart = /usr/sbin/clamd -c /etc/clamd.d/%i.conf --foreground=yes
Restart = on-failure
PrivateTmp = true
Now we can enable clamd@amavisd service
systemctl start clamd@amavisd
systemctl enable clamd@amavisd
systemctl status clamd@amavisd
Configure amavisd service
vim /etc/amavisd/amavisd.conf
At line 16 set number of amavisd childrens.
More childres uses more ram but delivers more mail at once, one amavisd children consumes near 30% of cpu in a low end server, be careful if you receive a lot of mails at once can be a big punch in your cpu have too many childrens.
$max_servers = <number>
line 20 set $mydomain
$mydomain = ‘’;
line 152 aprox set your hostname
$myhostname= ‘’;
Start service Amavisd
systemctl start amavisd.service
Enable service
systemctl enable amavisd.service
Step 7. Enable Apache and minim config.
yum -y install php php-devel php-gd php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap php-tidy curl curl-devel perl-libwww-perl ImageMagick libxml2 libxml2-devel mod_fcgid php-cli httpd-devel spamassassin unzip bzip2 unrar perl-DBD-mysql
systemctl start httpd.service
systemctl enable httpd.service
Edit config file
vim /etc/httpd/conf/httpd.conf
at line 86 edit with your admin email
# ServerAdmin root@localhost
at line 152 should be
## AllowOverride None
AllowOverride All
Config php
vim /etc/php.ini
at line 763 edit like this
at line 877 edit like this
;date.timezone =
date.timezone = Europe/Berlin
And now restart apache
systemctl restart httpd.service
Step 8. Setup Postfixadmin
Download Postxiadmin
 Move file to tar.gz file
mv postfixadmin-3.0.tar.gz\?r\=https\ postfixadmin-3.0.tar.gz
Extract folder
tar -zxvf postfixadmin-3.0.tar.gz -C /var/www/html/
cd /var/www/html/
chown -R root.apache postfixadmin-3.0/
 ln -s postfixadmin-3.0/ postfixadmin
We need to create postfix user database:
mysql -u root -p
MariaDB [(none)]> create database postfix;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> GRANT all on postfix.* to 'postfix'@'localhost' identified by 'yourPASSword';
Query OK, 0 rows affected (0.00 sec)
Now we have database, edit config file:
vim /var/www/html/postfixadmin/
$CONF[‘configured’] = true;
$CONF[‘setup_password’] = ‘YOUR-STRONG-PASSWORD’;
$CONF[‘database_type’] = ‘mysqli’;
$CONF[‘database_host’] = ‘localhost’;
$CONF[‘database_user’] = ‘postfix’;
$CONF[‘database_password’] = ‘yourPASSword’;
$CONF[‘database_name’] = ‘postfix’;
$CONF[‘show_password’] = ‘YES’;
$CONF[‘page_size’] = ’30’;
$CONF[‘default_aliases’] = array (
‘abuse’ => ‘’,
‘hostmaster’ => ‘’,
‘postmaster’ => ‘’,
‘webmaster’ => ‘’
$CONF[‘domain_path’] = ‘NO’;
$CONF[‘domain_in_mailbox’] = ‘YES’;
$CONF[‘maildir_name_hook’] = ‘NO’;
$CONF[‘transport’] = ‘YES’;
$CONF[‘vacation’] = ‘YES’;
$CONF[‘vacation_domain’] = ‘’;
$CONF[‘vacation_control’] =’YES’;
If your domain do not exist, activate this
Now got to browser and type http://your-ip/postfixadmin/setup.php and setup your admin password.
Setup Postfixadmin Now login and create new domain and email http://YOUR-IP-server/postfixadmin/login.php
Step 10   Setup Dovecot.
Now we enable IMAP and POP3 service.
vim /etc/dovecot/dovecot-sql.conf.ext
# The mysqld.sock socket may be in different locations in different systems
driver = mysql
connect = host=localhost dbname=postfix user=postfix password=yourpassword
# Default password scheme.
# depends on your $CONF['encrypt'] setting:
# md5crypt  -> MD5-CRYPT
# md5       -> PLAIN-MD5
# cleartext -> PLAIN
default_pass_scheme = MD5-CRYPT
# Query to retrieve password. user can be used to retrieve username in other
# # formats also.
password_query = SELECT username AS user,password FROM mailbox WHERE username = '%u' AND active='1'
# Query to retrieve user information.
## user_query = SELECT maildir, 1001 AS uid, 1001 AS gid FROM mailbox WHERE username = '%u' AND active='1'
user_query = SELECT CONCAT('/var/spool/vmail/', domain,'/', maildir) AS home, CONCAT('maildir:/var/spool/vmail/',domain,'/', maildir) AS mail, 5000 AS uid, 12 AS gid, concat('dict:storage=',CAST(ROUND(quota / 1024) AS CHAR), '::proxy::quota') AS quota, CONCAT('*:storage=',CAST(quota AS CHAR), 'B') AS quota_rule FROM mailbox WHERE username = '%u' AND active = '1'
Now we edit next file:
vim /etc/dovecot/conf.d/dovecot-mysql-quota.conf.ext
connect = host=localhost dbname=postfix user=postfix password=yourpassword
map {
  pattern = priv/quota/storage
  table = quota2
  username_field = username
  value_field = bytes
map {
  pattern = priv/quota/messages
  table = quota2
  username_field = username
  value_field = messages
vim /etc/dovecot/dovecot.conf
line 24 tells dovecot what protocols  should serve
protocols = imap pop3
line 31 is what interfaces where dovecot will be listening
listen = *, ::
line 44 welcome message,
#login_greeting = Dovecot ready.
login_greeting = Server OK.
line 69 defines behavior when reboot dovecot service
shutdown_clients = yes
Edit custom logging
vim /etc/dovecot/conf.d/10-logging.conf
line 8 log file
log_path = /var/log/dovecot.log
line 32 logging verbose password for debuging
#auth_verbose_passwords = no
auth_verbose_passwords = plain
line 41 enable debug password
#auth_debug_passwords = no
auth_debug_passwords = yes
Restart dovecot
systemctl restart dovecot.service
Create user for delivery internal and log.
useradd -r -u 5000 -g mail -d /var/spool/vmail -s /sbin/nologin -c "Virtual mailbox" vmail
Create folder vmail
mkdir /var/spool/vmail
change owner of log file
chown vmail /var/log/dovecot.log
Create logrotate for dovecot
vim /etc/logrotate.d/dovecot
/var/log/dovecot.log {
/bin/kill -USR1 `cat /var/run/dovecot/ 2>/dev/null` 2> /dev/null || true
Config authenticated user
vim /etc/dovecot/conf.d/10-auth.conf
line 10 disable plain test on
disable_plaintext_auth = yes
Auth mecanism
auth_mechanisms = plain login cram-md5
and databate type user setup
#!include auth-system.conf.ext
!include auth-sql.conf.ext
Setup SSL
SSL protocols
ssl_protocols = !SSLv2 !SSLv3
SSL ciphers to use
Prefer the server’s order of ciphers over client’s.
ssl_prefer_server_ciphers = yes
 Now dovecot needs to know what protocols will  serve and how
vim /etc/dovecot/conf.d/10-master.conf
service imap-login {
  inet_listener imap {
    port = 143
  inet_listener imaps {
    port = 993
    ssl = yes
service pop3-login {
  inet_listener pop3 {
    port = 110
  inet_listener pop3s {
    port = 995
    ssl = yes
service auth {
  unix_listener /var/spool/postfix/private/auth {
    mode = 0666
    user = vmail
    group = mail
Enable sieve in dovecot
vim /etc/dovecot/conf.d/15-lda.conf
protocol lda {
# Space separated list of plugins to load (default is global mail_plugins).
#mail_plugins = $mail_plugins
mail_plugins = $mail_plugins sieve
end for today

File underconstruction ……  please return back in few days.