User Tools

Site Tools


Sidebar

js#vista.png msort nsort

mail:hostingserver-autoresponder

Autoresponder for Hosting Mail Server w/ Exim, Courier/Dovecot, SA, ClamAV & Greylistd

In Hosting Mail Server w/ Exim, Courier/Dovecot, SA, ClamAV & Greylistd we saw a nice way to get a full fledged hosting level mailing server up and running. One of the few points I found missing was the support for vacation autoresponders.

To close this small hole in the feature list here is a nice way to get vacation autoresponders working.

in /etc/exim4/conf.d/router/076_mailMEO_vacation

     driver = accept
     local_parts = ${lookup ldap {USER=uid=exim,dc=bongobongo,dc=de PASS=asdlkfjaod ldap:///dc=MAILMEO_MAINDOMAIN,MAILMEO_DOMAINROOT?uid?sub?(&(objectClass=inetLocalMailRecipient)(uid=$local_part))}}
     # do not reply to errors or lists
     condition = "${if or {{match {$h_precedence:} {(?i)junk|bulk|list}} {eq {$sender_address} {}}} {no} {yes}}"
     no_expn
     debug_print = "R: vacaation mail for $local_part@$domain" 
     require_files = /home/${substr_0_1::$domain}/$domain/$local_part/vacation.msg
     # do not reply to errors and bounces or lists
     senders = " ! ^.*-request@.*:\
                 ! ^owner-.*@.*:\
                 ! ^postmaster@.*:\
                 ! ^listmaster@.*:\
                 ! ^mailer-daemon@.*\
                 ! ^root@.*"
     transport = vacation_reply
     unseen
     no_verify

In /etc/exim4/conf.d/trasport/30_exim4-config_vacation add the following:

vacation_reply:
     driver = autoreply
     file = /home/${substr_0_1:$domain}/$domain/$local_part/vacation.msg
     file_expand
     from = Autoreply System <$original_local_part@$original_domain>
     log = /home/${substr_0_1:$domain}/$domain/$local_part/vacation.log
     once = /home/${substr_0_1:$domain}/$domain/$local_part/vacation.db
     once_repeat = 7d
     headers = MIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit
     subject = ${if def:h_Subject: {Re: ${quote:${escape:${length_50:$h_Subject:}}} (autoreply)} {I am on vacation} }
     text = "\
     Dear $h_from\n\n\
     This is an automatic reply.  Feel free to send additional\n\
     mail, as only this one notice will be generated.  The following\n\
     is a prerecorded message, sent for $original_local_part@$original_domain:\n\
     ====================================================\n\n\
     "
     to = "$sender_address"

     user = mail
     group = mail

Restart Exim4 and all that is left is to add the vacation.msg and vacation.db files to the users home directory.

In the users home directory create the vacation.msg file and add the vacation message to be sent. Afterwards create the vacation.db and make sure the Exim4 mail user can access it.

touch /home/b/bongobongo/aa01/vacation.db
chown mail. /home/b/bongobongo/aa01/vacation.db

Enjoy your vacation mails.

mail/hostingserver-autoresponder.txt · Last modified: 2020/02/24 11:16 (external edit)