Exim mail server have auto-reply or vacation autoresponder feature missing in default configuration.  It can be easily achieved by providing right Router and Transport configuration using Exim configuration.

Our setup contains exim + dovecot running imap on CPanel/WHM dedicated server. Dovecot imap using maildir format and default location for storing mail is /home/vmail/$domain/$user.

1- Exim Router Configuration.

Following lines should be inserted in Router configuration area inside /etc/exim/exim.conf

######################################################################
#                  ROUTERS CONFIGURATION                             #
#
#..
# This router delivers an auto-reply "vacation" message if a file called 'vaction.msg'
# exists in the home directory.

uservacation:
  driver = redirect
  domains = +local_domains
  allow_filter
  user = vmail
  group = vmail
  file = /home/vmail/${domain}/${local_part}/.vacation.msg
  require_files = /home/vmail/${domain}/${local_part}/.vacation.msg
  # do not reply to errors or lists
  condition = ${if or { \
  {match {$h_precedence:} {(?i)junk|bulk|list}} \
  {eq {$sender_address} {}} \
  } {no} {yes}}
  # do not reply to errors or bounces or lists
  senders = ! ^.*-request@.*:\
  ! ^bounce-.*@.*:\
  ! ^.*-bounce@.*:\
  ! ^owner-.*@.*:\
  ! ^postmaster@.*:\
  ! ^webmaster@.*:\
  ! ^listmaster@.*:\
  ! ^mailer-daemon@.*:\
  ! ^root@.*
  no_expn
  reply_transport = uservacation_transport
  unseen
  no_verify

Above configuration will instruct exim to route any message if you found .vacation.msg file in the home maildir of user. You can edit the maildir location to match yours user maildir.

2- Exim Transport Configuration

Following lines should be inserted in Transport configuration area inside /etc/exim/exim.conf

######################################################################
#                TRANSPORTS CONFIGURATION                            #
#...
uservacation_transport:
  driver = autoreply
  user = vmail
  group = vmail
  file = /home/vmail/${domain}/${local_part}^/.vacation.msg
  file_expand
  once = /home/vmail/${domain}/${local_part}^/.vacation.db
  # to use a flat file instead of a db specify once_file_size
  #once_file_size = 2K
  once_repeat = 14d
  from = ${local_part}@${domain}
  to = ${sender_address}
  subject = "Re: $h_subject"

.vacation.db will save all the mail addresses to whom it auto-replied the messages. You can edit the maildir location to match yours user maildir.

3- Maildir Vacation files

Following files inside your maildir needs to be there to send reply back to the sender. In my situation is /home/vmail/$domain/$user/

.vacation.msg

# Exim filter
if ($h_subject: does not contain "SPAM?" and personal) then
mail
##### This is the only thing that a user can set when they #####
##### decide to enable vacation messaging. The vacation.msg.txt #####
expand file /home/vmail/${domain}/${local_part}/.vacation.msg.txt
log /home/vmail/${domain}/${local_part}/.vacation.log
to $reply_address
from $local_part\@$domain
subject "Unmonitored Mailbox [Re: $h_subject:]"
endif

.vacation.msg.txt

Hi,

This is test reply.

Regards,

These two files in any user maildir will makes it auto-reply.

Please use comments for any questions.

By Sohail Riaz

I am a First Red Hat Certified Architect - RHCA (ID # 110-082-666) from Pakistan with over 14 years industry experience in several disciplines including LINUX/UNIX System Administration, Virtualization, Network, Storage, Load Balances, HA Clusters and High Performance Computing.

4 thoughts on “Auto-Reply for Exim Mail Server”

Leave a Reply

Your email address will not be published. Required fields are marked *