I hate vacation messages but business people tend to want them. They’re easy to do by the user on Exchange but it’s a bit harder on pure IMAP/POP based services since it’s not all integrated into one with the mail client.
Exim can do vacation messages using its Autoreply Transport. It supports all the usual stuff like only notifying a specific sender once every couple of days etc.
To get this going requires two bits of config, first you need a router. Routers in the exim configuration is processed top-down as they appear in the config file, so you’ll want to put the vacation handling above any localuser handling, virtual hosting etc.
A sample router is shown below, it’s for local users and they just have to put a .vacation file in their home directory to activate the functionality, the .vacation file should contain the text they want mailed. You can easily adapt the location of this to be in your virtual mail hierarchy by changing the file locations below:
uservacation: driver = accept domains = +local_domains require_files = $home/.vacation # 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 transport = uservacation_transport unseen no_verify
You’ll notice that it does not autoreply to certain people, the kind of from addresses that mailing lists typically use, it will also ignore bounce messages.
Once you have the router configured you’ll need a transport, this will call the autoreply transport and do the hard work. It will use a Berkley style database in ~/.vacation.db to store the list of people it has contacted in the last 14 days. Users can just delete this file if they want to reset it all.
uservacation_transport: driver = autoreply file = $home/.vacation file_expand once = $home/.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"
That should do it, in a virtual domain setup you could easily integrate this into a web interface that maintains the text files required, there are other features like a standard prefix before each vacation message etc, refer to the Exim Documentation for details on these.