aboutsummaryrefslogtreecommitdiff
path: root/etc/mailfromd.rc
blob: ab684b8ed224e16f6c54947f5ad3ca4a626c49d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/* This is a sample start-up script for mailfromd.       -*- mfl -*-
   Site administrators are urged to write nicer versions.
   Copyright (C) 2005, 2006, 2007 Sergey Poznyakoff

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
   MA 02110-1301 USA */

#error "Do not use this file 'AS IS'! Tailor it to suit your site!"

#pragma option relay "/etc/mail/sendmail.cw"
#pragma option relay "/etc/mail/relay-domains"
#pragma regex +extended +icase
#pragma option debug 1

#include_once <status.mfh>
#require dns

set mailfrom_address "<>"
set ehlo_domain "your.domain"

number gltime
set gltime interval("1 hour")
number need_greylist
set need_greylist 0

func cachestr() returns string
do
  if %cache_used
    return "[CACHED] "
  else 
    return ""
  fi
done

prog envfrom
do
  if $f = ""
    pass 
  elif hostname ${client_addr} matches ".*(adsl|sdsl|hdsl|ldsl|dialin|dialup|ppp|dhcp|dynamic).*"
    reject 550 5.7.1 "Use your SMTP relay"
  elif hostname ${client_addr} matches ".*-[0-9]{1,3}-[0-9]{1,3}-[0-9]{1,3}-[0-9]{1,3}.*"
    on poll host ${client_addr} for $f
    do
    when success:
      pass
    when not_found or failure:
      reject 550 5.1.0 cachestr() "Sender validity not confirmed"
    when temp_failure:
      tempfail 450 4.1.0 "Try again later"
    done
  elif relayed hostname ${client_addr} 
    pass
  elif $f mx fnmatches "*.yahoo.com"
    or $f mx fnmatches "*.namaeserver.com"
    set need_greylist 1
  else
    on poll $f do
    when success:
      pass
    when not_found or failure:
      reject 550 5.1.0 cachestr() "Sender validity not confirmed"
    when temp_failure:
      tempfail
    done
  fi

  if rate($f "-" ${client_addr}, interval("1 hour 30 minutes")) > 100
    tempfail 450 4.7.0 "Mail sending rate exceeded. Try again later"
  fi
done

prog envrcpt
do
  if %need_greylist
     and not dbmap("/var/run/whitelist.db", $client_addr)
    if greylist($client_addr "-" $f "-" $rcpt_addr, %gltime)
      if %greylist_seconds_left = %gltime
	tempfail 450 4.7.0
	         "You are greylisted for " %gltime " seconds"
      else
	tempfail 450 4.7.0
                "Still greylisted for "
                %greylist_seconds_left " seconds"
      fi
    fi
  fi
done


Return to:

Send suggestions and report system problems to the System administrator.