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
1. 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.
2. Add the RPMforge repository. The RPMforge repository is needed to install the required modules for the vacation.pl script.
3. 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
4. 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 vacation.pl to the vacation user home directory.
cd /home/vacation
wget www.linuxmail.info/files/vacation.pl
chown vacation:vacation vacation.pl
chmod 700 vacation.pl
Configuring Postfix
1. 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
vacation unix - n n - - pipe flags=Rq user=vacation
argv=/home/vacation/vacation.pl ${recipient} ${original_recipient}
${original_recipient} requires at least Postfix 2.5 but you can remove it if you prefer not to upgrade. It enables vacation.pl to work with aliases like in the example below.
Email (original recipient) | Forwards to (recipient) |
---|---|
john@acme.local | johndoe@acme.local |
jane@acme.local | janedoe@acme.local |
3. Create the file /etc/postfix/mysql-aliases.cf containing the lines below.
host = localhost
user = postfix
password = your_password
dbname = postfix
table = alias
select_field = goto
where_field = address
additional_conditions = and active = '1'
user, password, dbname should match your PostfixAdmin settings.
virtual_alias_maps = mysql:/etc/postfix/mysql-aliases.cf
transport_maps = hash:/etc/postfix/transport
If you already have an existing virtual_alias_maps, add the mysql-aliases into the end like the one below.
virtual_alias_maps = ldap:/etc/postfix/ldap-groups.cf,
mysql:/etc/postfix/mysql-aliases.cf
If adding the vacation domain conflicts with your existing virtual_alias_maps, use recipient_bcc_maps instead and replace /etc/postfix/mysql-aliases.cf with 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@vacation.invalid
5. Restart the Postfix or MailScanner service if you have installed it. Learn how to start and stop services here.
Configuring the Vacation Perl Script
1. Create the file /home/vacation/vacation.conf containing the lines below.
$db_username = 'postfix';
$db_password = 'secret';
$db_name = 'postfix';
$test_mode = 0;
1;
$db_username, $db_password, $db_name should match your PostfixAdmin settings.
postmap -q johndoe@acme.local mysql:/etc/postfix/mysql-aliases.cfReplace johndoe@acme.local with the email address where you have configured a vacation message. The output should contain an email address for the vacation.invalid domain.