on March 29 | in Hosting / Servers, Linux | by Sohail Riaz | with 4 Comments

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 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 ###################################################################### # 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" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ###################################################################### # 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 1 2 3 4 5 6 7 8 9 10 11 # 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, 1 2 3 4 5 Hi , This is test reply . Regards ,

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

Please use comments for any questions.

about the author: 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.

related posts

« Update Cobbler Signature File Recover InnoDB tables using .frm and .ibd files »