I think, therefore I blog

Exim Autoreply Example (Exim4)

By , 10 October 2010

Exim Autoreply Example (Exim4)

Here is some example Exim configuration for email autoreply where the email accounts and response text are kept in a postgresql database. First add a new router to the routers section like this one:

# Autoreply router which may pass messages to the autoreply transport.
# Unseen must be used to ensure the message is also delivered by passing
# it to the next router.
  driver = accept
  transport = autoreply
  condition = ${lookup pgsql{SELECT 1 FROM email_accounts a \
	    WHERE a.localpart = '${quote_pgsql:$local_part}' AND \
	          a.domain = '${quote_pgsql:$domain}' AND \
                  a.autoreply = true}}

And in the transports section add the following.

# Autoreply transport. The entire autoreply email needs to built from 
# scratch.
  driver = autoreply
  to = ${reply_address}
  from = ${local_part}@${domain}
  subject = Re: $h_subject:
  text = ${lookup pgsql{SELECT autoMessage FROM email_accounts a \
	    WHERE a.localpart = '${quote_pgsql:$local_part}' AND \
	          a.domain = '${quote_pgsql:$domain}' AND \
                  a.autoreply = true}}
Exim Autoreply Example (Exim4)

There is also a 'once' option on the transport to prevent duplicate autoreplies being sent, but I haven't implemented it in this example because it is unclear from the exim docs if this will work with multiple email accounts. That is, if more than one user on the server has an email autoreply enabled, we want to reply once per user, not just once total as the docs seem to indicate.

Let me know if I interpreted the documentation wrongly :)


About Roger Keays

Exim Autoreply Example (Exim4)

Roger Keays is an artist, an engineer, and a student of life. Since he left Australia in 2009, he has been living as a digital nomad in over 40 different countries around the world. Roger is addicted to surfing. His other interests are music, psychology, languages, and finding good food. Click here to subscribe to his weekly blog, or stalk him on Facebook and Twitter.

Leave a Comment

Please visit https://RogerKeays.com/blog/exim-autoreply-example-exim4 to add your comments.

Join Over 1000 Subscribers

I write every Sunday about travel, psychology, and technology. Thousands of people just like you have already subscribed—and for good reason. It'll change your life. And it's free :)

Read a Good Book

“A spellbinding true story of love, passion and adventure. One can’t help but be swept away by 100% Love Guaranteed.” —Dr Tammie Matson, author of Elephant Dance.

Chat For A While

Your Vote Matters

Which animal will take over when humans go extinct?