V

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
autoreply_deferentially [2016-05-03 16:56]
andreas [Use with caution] Updated links due to link rot
autoreply_deferentially [2017-09-27 15:37] (current)
andreas [Usage/Installation] Exchange Exception
Line 1: Line 1:
 +====== autoreply_deferentially.rc ======
 +
 +A [[man>​procmail]] based autoreply/​autoresponder/​vacation script
 +
 +===== Description =====
 +
 +There is a number of programs available which allow users to set up automatic mail replies. One of the oldest is [[man>​vacation]]. [[man>​procmail]] even features some recipes in the [[man>​procmailex]] manpages. Anyway, ''​autoreply_deferentially.rc''​ tries to be more cautious and to reply (hopefully) only to directly addressed, personal messages.
 +
 +===== Use with caution =====
 +
 +Please note that autoreply software is essentially tricky and can cause a lot of trouble. Many administrators discourage the use of such software. Here are some discussions of pros and cons:
 +
 +  * [[http://​website.lineone.net/​~saphena/​emailauto.html|Email autoreplies - don't use them!]]
 +  * [[http://​wayback.archive.org/​web/​20100226135750/​http://​forum.spamcop.net/​forums/​lofiversion/​index.php/​t5693.html|SpamCop Discussion: Why are auto-responders bad, in simple terms?]]
 +  * [[https://​www.spamcop.net/​fom-serve/​cache/​329.html |SpamCop FAQ: Why are auto responders bad?]]
 +  * [[http://​www.hoax-slayer.com/​email-auto-reply-caution.shtml|Use Email Auto-Replies With Caution]]
 +
 +===== Features =====
 +
 +  * Tries to reply only to directly addressed, personal messages
 +  * Supports [[regex_mail_receipts]] (needs to be uncommented to enable)
 +  * Writes its own concise log (address + time)
 +  * Loosely respects RFC [[rfc>​3834]]
 +  * [[blog:​091116_autoreply_deferentially_or_better_not_at_all|Author suggests not to send autoreplies]],​ never ever
 +  * Suitable for sincere users only
 +
 +===== Source code =====
 +
 +The following shows the core part of the script (slightly simplified). For the full code including more comments, variables'​ settings and defaults, download {{:​misc:​autoreply_deferentially.rc}}.
 +
 +<code bash>
 +# --- send autoreply to senders (in case you received a _personal_ message)
 +:0
 +* AR_AUTOREPLY ?? yes
 +* $!^X-Loop: $AR_MYADDRESS
 +{
 +  :0 Whc: autoreply_deferentially.lock
 +  # Check to see if the mail was addressed to us
 +  * $^(To|CC): (.*\<​)?​$AR_MYADDRESS
 +  # Don't reply to daemons and mailinglists,​ junk, and other mass mailings
 +  * !^FROM_DAEMON
 +  * !(^List|mail(ing|(ing)?​[- _]?​list)|-l@|newsletter)
 +  #* !^Precedence:​ (list|junk|bulk) # this is included in ^FROM_DAEMON
 +  * !^X-Spam-Status:​ .*DCC_CHECK
 +  # Never reply to ourselves
 +  * $!^From: .*$AR_MYADDRESS
 +  # Miscellaneous criteria
 +  * !^(X-Sent-)?​From:​ .*((www|web)-?​(data|master|admin)|(apache|robot)@)
 +  * !^(From|Reply-To):​ .*(noreply|confirm|request|<>​)
 +  * !^Content-Type:​ multipart/​report
 +  * !^User-Agent:​ rss2email
 +  # RFC 3834 suggests to accept only "​Auto-Submitted:​ no"
 +  * !^Auto-Submitted:​ ...
 +  # Don't reply to receipts (delivery notifications,​ out of office, ...)
 +  * !^User-Agent:​ Vacation
 +  * !^X-Mailer:​.*auto.?​(reply|mail)
 +  * !^X-Webmin-Autoreply:​ 1
 +  # A MS specific header (we ignore value '​None'​ since it was never seen)
 +  * !^X-Auto-Response-Suppress:​ ..
 +  # cPanel and BoxTrapper
 +  * !^X-Precedence:​ auto_reply
 +  # CommunicatePro sets (still?) X-Autogenerated:​ reply
 +  * !^X-Autogenerated:​ reply
 +  # Get a filter list e.g. from http://​wox.at/​as/​_/​regex_mail_receipts
 +  ###* !? grep -Ef /​etc/​procmailrc_receipts ​ ### uncomment if available
 +  # Do not reply to some selected addresses (local blacklist)
 +  * !^From: .*(@example.com|wf-batch@brz\.gv\.at)
 +  # Make sure the autoreply text exists
 +  * ? test -r $AR_MSGFILE
 +  # Mail loops are evil
 +  | $AR_FORMAIL -rtD 65532 "​$AR_VACATION_CACHE"​
 +
 +  :0 ec         # if the senders address was not in the cache
 +  {
 +    # Get address to send reply to and write a line to $AR_LOGFILE
 +    :0
 +    * ^From:​.*\/​(<?​[a-z0-9_][-a-z0-9_+.=]*@[-a-z0-9.]+[a-z0-9]>?​)
 +    { # Logging the sent autoreplies
 +      AR_NOW=`date +%Y-%m-%d\ %H:%M`
 +      AR_LOGFILEBAK="​$LOGFILE"​
 +      LOGFILE="​$AR_LOGFILE"​
 +      LOG="​$MATCH $AR_NOW$AR_NL"​
 +      LOGFILE="​$AR_LOGFILEBAK"​
 +    }
 +    # Write a message to the default procmail log
 +    LOG=" ​  >>>​ sending autoreply to $MATCH $AR_NL"​
 +    # Send autoreply message
 +    :0 h
 +    | ($AR_FORMAIL -rtA"​Precedence:​ junk" -A"​Auto-Submitted:​ auto-replied"​ \
 +      -A"​X-Auto-Response-Suppress:​ All" \
 +      -A"​X-Loop:​ $AR_MYADDRESS"​ -A"​From:​ $AR_FROMADDRESS"​ \
 +      -A"​$AR_EXTRAHEADERS"​ ;\
 +      cat $AR_MSGFILE \
 +      ) | $AR_SENDMAIL -i -t
 +  }
 +}
 +</​code>​
 +
 +===== Usage/​Installation =====
 +
 +I hope it is sufficiently obvious that this should not be used at all unless one at least roughly understands what the procmail recipes are doing. Anyway, please, download the full code and look at the comments for further instructions. Don't forget to provide the file in ''​$AR_MSGFILE''​ and to remove ''​$AR_VACATION_CACHE''​ if an old version exists.
 +
 +==== Exchange Exception ====
 +
 +My colleague Johann Klasek kindly reported that our university'​s Exchange server redirects messages in a way that causes this procmail recipe to skip sending autoreplies for all messages because Exchange adds the header ''​Auto-Submitted:​ auto-generated''​. He also provided a clever hack to make it work:
 +
 +We need to change the line
 +
 +<​code>​
 +  * !^Auto-Submitted:​ ...
 +</​code>​
 +
 +to
 +
 +<​code>​
 +  * !^Auto-Submitted:​$AR_IGNORERFC3834 ...
 +</​code>​
 +
 +and add the following recipe to set ''​$AR_IGNORERFC3834''​ for redirected messages:
 +
 +<code bash>
 +:0
 +* ^x-ms-exchange-parent-message-id:​
 +{
 +  # Message redirected by MS Exchange: skip check for RFC 3834 header
 +  AR_IGNORERFC3834=MS-Exchange
 +}
 +</​code>​
 +
 +This needs to be included right above
 +
 +    :0 Whc: autoreply_deferentially.lock
 +
 +
 +===== Download =====
 +
 +{{:​misc:​autoreply_deferentially.rc}}
 +
 +===== Disclaimer =====
 +
 +Use at your own risk! Tested only on Debian 6 & 7.
 +
 +===== Discussion =====
 +
 +  * [[blog:​091116_autoreply_deferentially_or_better_not_at_all]]
  
 
autoreply_deferentially.txt ยท Last modified: 2017-09-27 15:37 by andreas