This article describes how to configure a vacation autoresponder in Postfix mail server so email senders can be informed when the recipient is not available.

Installing the Vacation Perl Script

Postfix Admin Main1. Install Postfix Admin. We are not going to actually use Postfix Admin, we are just going to leverage its excellent vacation message infrastructure. You can skip this part if you are actually using Postfix Admin to manage your Postfix mail server.
Install EPEL2. Add the EPEL repository. The EPEL repository is needed to install the required modules for the script.
yum install3. Type in the command below to install the required Perl modules.
yum install perl-MIME-EncWords perl-MIME-Charset
   perl-Email-Valid perl-Mail-Sendmail
Create user vacation4. Create a new user named vacation. Change the Login Shell to /sbin/nologin, this user account should not be used for logging in. Learn how to use the User Manager application here.
5. Type in the commands below to copy to the vacation user home directory.
cd /home/vacation
chown vacation:vacation
chmod 700
chcon -t postfix_pipe_exec_t
vacation.pl6. Type in the command below to test No error should appear.

Configuring Postfix

postconf1. Install a version of Postfix with MySQL support. The Postfix in RHEL/CentOS 6 already includes MySQL support.
Install postfixmysql.te2. If you are using RHEL/CentOS 6, configure SELinux using the commands below. Here’s the content of postfixmysql.te
checkmodule -M -m -o postfixmysql.mod postfixmysql.te
semodule_package -o postfixmysql.pp -m postfixmysql.mod
semodule -i postfixmysql.pp
Edit transport
3. Edit the file /etc/postfix/transport and add the line below.
vacation.invalid vacation:
Next, type in the command below to convert it to a database file.
postmap /etc/postfix/transport
Edit master.cf4. Edit the file /etc/postfix/ and add the line below.
vacation unix - n n - - pipe flags=Rq user=vacation
   argv=/home/vacation/ ${recipient} ${original_recipient}
Note${original_recipient} requires at least Postfix 2.5 (RHEL/CentOS 6 includes Postfix 2.6) but you can remove it if you prefer not to upgrade. It enables to work with aliases like in the example below.
(original recipient)
Forwards to
Edit transport5. Edit the file /etc/postfix/ and add the lines below.
transport_maps = hash:/etc/postfix/transport
vacation_destination_recipient_limit = 1
If you are not using PostfixAdmin to manage your domains and user accounts, add the line below.
recipient_bcc_maps = mysql:/etc/postfix/
The file /etc/postfix/ should contain the lines below.
host = localhost
user = postfix
password = your_password
dbname = postfix
table = vacation
select_field = email
where_field = email
additional_conditions = and active = '1'
result_format = %u#%d@vacation.invalid

user, password, dbname should match your PostfixAdmin settings.

Service Configuration6. Restart the Postfix or MailScanner service if you have installed it. Learn how to start and stop services here.
SquirrelMail Test Vacation7. Send an email to test@vacation.invalid. You should get an automated reply.

Configuring the Vacation Perl Script

Edit vacation.conf1. Create the file /etc/postfix/vacation.conf containing the lines below.
$db_username = 'postfix';
$db_password = 'secret';
$db_name     = 'postfix';
$test_mode   = 0;

$db_username, $db_password, $db_name should match your PostfixAdmin settings.

SquirrelMail Options3. Set a vacation message to a user in SquirrelMail using the newly installed plugin.
postmap vacation4. Verify your vacation setting by typing the command below.
postmap -q johndoe@acme.local mysql:/etc/postfix/
or if you are using PostfixAdmin
postmap -q johndoe@acme.local mysql:/etc/postfix/
Replace johndoe@acme.local with the email address where you have configured a vacation message. For PostfixAdmin users, replace with your own aliases map file. The output should contain an email address for the vacation.invalid domain.
SquirrelMail Auto Response5. Send an email to the user with a vacation message. You should receive an automatic reply.
NoteIf you encounter any problems, check the log file at /var/log/maillog.

Visit the forum to ask for help or to give a comment.

Posted on 7/11/2009 and last updated on 6/23/2012
Filed under Postfix