CentOS Server Autoresponder

Building and configuring a production ready mail server with virtual users is challenging and it is something that should be approached one step at a time. This year (2015) I will be upgrading dodify's mail server hardware and I will improve my configuration and software stack considerably. Sometimes however you need something "quick and dirty", for example when a user asks for autoresponder functionality but none is available! I plan to let users configure their own autoresponse messages on the new mail server but for a quick one off I had to find a good and simple solution.

Here is a quick tutorial on how to get the autoresponse script provided by nefaria.com working on a CentOS server. Please note:

  • The script is one file so very easy to understand;
  • I will assume a standard virtual user configuration. In my case Postfix with Dovecot;
  • The script is considered deprecated by the author;
  • The script was written for Fedora and Ubuntu;
  • The documentation provided was sufficient to get the script working in a matter of minutes;
  • The script configured as per this tutorial does not send autoresponse messages to virtual users on the same mail server.

Installation

The first few steps are simple. Download the script, uncompress it and create/prepare the relevant system user and folders the script will use. As root user you can achieve this with the following commands:

mkdir ~/tmp && cd ~/tmp
wget http://www.nefaria.com/scriptz/autoresponse-1.6.3.tar.gz
tar xvfz autoresponse-1.6.3.tar.gz
useradd -d /var/spool/autoresponse -s `which nologin` autoresponse
mkdir -p /var/spool/autoresponse/log /var/spool/autoresponse/responses
cp autoresponse /usr/local/sbin/
chown -R autoresponse.autoresponse /var/spool/autoresponse
chmod -R 0770 /var/spool/autoresponse

You will then have to edit your postfix configuration so that postfix will send incoming messages to the autoresponder script as well as delivering them to the relevant mail directories. Open /etc/postfix/master.cf using vi and look for the following line:

smtp      inet  n       -       n       -       -       smtpd

And add the following directly below it ensuring you start the line with at least one whitespace character:

-o content_filter=autoresponder:dummy

Also add the following two lines near the bottom of the file after the other external delivery methods comment:

autoresponder unix - n n - - pipe
  flags=Fq user=autoresponse argv=/usr/local/sbin/autoresponse -s ${sender} -r ${original_recipient} -S ${sasl_username} -C ${client_address}

After you save and quit the changes run the following to configure postfix correctly and reload:

postconf -e 'autoresponder_destination_recipient_limit = 1'
/etc/init.d/postfix restart

Using the Script

Although you can configure autoresponse messages via email I won't cover this here as ideally users would have a better way of doing so. The server admin can however very easily configure autoresponse messages using the following four commands:

autoresponse -e user@domain.tld
autoresponse -d user@domain.tld
autoresponse -E user@domain.tld
autoresponse -D user@domain.tld

The four commands in order achieve the following results:

  • Create autoresponse message for user@domain.tld;
  • Disable autoresponse message for user@domain.tld;
  • Enable autoresponse message for user@domain.tld;
  • Delete autoresponse message for user@domain.tld.

When creating an autoresponse message the script will launch vi where you can simply type your message.