Re: [exim] Outofdate email

Top Page
Delete this message
Reply to this message
Author: Mar Matthias Darin
Date:  
To: Exim Users List
Subject: Re: [exim] Outofdate email
Hello,

Michael L Griffin writes:

> I often receive email that is a few days / months / years "old"
> according to the email date 99.99% of which is SPAM.
>
> Now a thought, what would the benefit/negative be in denying
> incoming email "older" than say 7 days? I was thinking that denying
> at connection time would alleviate load on SpamAssasin (my resources
> are limited on a VPS).
>
> Any ideas on how best to do this? Pointers / examples greatly
> appreciated as always.


The following will do exactly what you are seeking.

First the bash script:

---[ Start: CheckDate ] ----
#!/bin/sh
#
# Check message age
#
# $1 - message date
# $2 - Max past age accepted
# $3 - Max future age accepted

export PATH=/bin:/usr/bin:/usr/local/bin

# Date/time of Message

D=`date -d "$1" +"%s"`

# Current Data/time

N=`date +"%s"`

# Elapsed time, negative number a future dates

let E=$N-$D

# Age of message in days, negative numbers are future

let A=$E/86400

if [ $A -lt 0 ] ; then
  let A=A*-1
  if [ $A -gt $3 ] ; then
    exit 2
  fi
fi 


if [ $A -gt $2 ] ; then
exit 1
fi

exit 0
--- [ End: CheckDate ] ---

Save this file in the /usr/exim folder as: CheckDate
Then make it executable.

Now for the Exim conf lines:

acl_check_data:
  deny    condition     = ${if or 
{{!def:h_Date:}{!def:h_Subject:}{!def:h_To:}}{yes}{no}}
          message       = Message does not conform to RFC2822 standard


  deny    set acl_m8    = ${run{/usr/exim/CheckDate "$h_date:" 30 3}}
          condition     = ${if eq {$runrc}{1}{yes}{no}}
          message       = Message too out of date


  deny    condition     = ${if eq {$runrc}{2}{yes}{no}}
          message       = Message from the future 



The conditions are one line only, wrapped by email client. This says to
deny any massage older then 30 days or any message 3 or more days in the
future. The numbers can be changed as desired. They are in DAYS referenced
from "today".

---

DynaStop: Stopping spam one dynamic IP address at a time.
http://tanaya.net/DynaStop/