exim_path = /usr/sbin/exim4
CONFDIR = /etc/exim4

domainlist local_domains = @:miranda.sommitrealweird.co.uk:sommitrealweird.co.uk:localhost
domainlist relay_to_domains = 

hostlist relay_from_hosts = 127.0.0.1:195.10.223.140
qualify_domain = sommitrealweird.co.uk

DCreadhost = sommitrealweird.co.uk
daemon_smtp_ports = 25 : 587

tls_certificate = /etc/exim4/exim.crt
tls_privatekey = /etc/exim4/exim.key

tls_advertise_hosts = *

LOCAL_DELIVERY=maildir_home

av_scanner = clamd:/var/run/clamav/clamd.ctl

gecos_pattern = ^([^,:]*)
gecos_name = $1

acl_smtp_rcpt = acl_check_rcpt

acl_smtp_data = acl_check_data

rfc1413_hosts = *
rfc1413_query_timeout = 2s

local_from_check = false
local_sender_retain = true
untrusted_set_sender = *

ignore_bounce_errors_after = 2d

timeout_frozen_after = 7d

freeze_tell = postmaster

spool_directory = /var/spool/exim4

trusted_users = uucp:brettp:Debian-exim
trusted_groups = Debian-exim

message_size_limit = 5M

begin acl

acl_whitelist_local_deny:
  accept hosts = ${if exists{CONFDIR/local_host_whitelist}\
                        {CONFDIR/local_host_whitelist}\
                        {}}
  accept senders = ${if exists{CONFDIR/local_sender_whitelist}\
                        {CONFDIR/local_sender_whitelist}\
                        {}}

acl_check_rcpt:
  accept hosts = :

  deny    domains       = +local_domains
          local_parts   = ^[.] : ^.*[@%!/|]
          message       = restricted characters in address

  deny    domains       = !+local_domains
          local_parts   = ^[./|] : ^.*[@%!] : ^.*/\\.\\./
          message       = restricted characters in address

  accept local_parts = postmaster
         domains = +local_domains

  deny message = sender envelope address $sender_address is locally blacklisted here. If you think this is wrong, get in touch with postmaster
       !acl = acl_whitelist_local_deny
       senders = ${if exists{CONFDIR/local_sender_blacklist}\
                             {CONFDIR/local_sender_blacklist}\
                             {}}

  deny message = sender IP address $sender_host_address is locally blacklisted here. If you think this is wrong, get in touch with postmaster
       !acl = acl_whitelist_local_deny
       hosts = ${if exists{CONFDIR/local_host_blacklist}\
                             {CONFDIR/local_host_blacklist}\
                             {}}

  accept domains = +local_domains
         endpass
         message = unknown user
         verify = recipient

  accept domains = +relay_to_domains
         endpass
         message = unrouteable address
         verify = recipient

  accept hosts = +relay_from_hosts

  accept authenticated = *

  deny message = relay not permitted

acl_check_data:

   accept condition = ${if eq {$received_protocol}{spam-scanned} {yes}{no}}

   warn condition = ${if !def:h_Message-ID: {1}}
        hosts = +relay_from_hosts
        message = Message-ID: <E$message_id@$primary_hostname>

   deny message = Serious MIME defect detected ($demime_reason)
        demime = *
        condition = ${if >{$demime_errorlevel}{2}{1}{0}}

   deny message = Bad file attachment
        demime = exe:com:vbs:bat:pif:scr

   deny message = This message contains malware ($malware_name)
        demime = *
        malware = *

   accept

begin routers

dnslookup:
  debug_print = "R: dnslookup for $local_part@$domain"
  driver = dnslookup
  domains = ! +local_domains
  transport = remote_smtp
  same_domain_copy_routing = yes
  ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8 : 192.168.0.0/16 :\
                        172.16.0.0/12 : 10.0.0.0/8 : 169.254.0.0/16
  no_more

real_local:
  debug_print = "R: real_local for $local_part@$domain"
  driver = accept
  domains = +local_domains
  local_part_prefix = real-
  check_local_user
  transport = LOCAL_DELIVERY

system_aliases:
  debug_print = "R: system_aliases for $local_part@$domain"
  driver = redirect
  domains = +local_domains
  allow_fail
  allow_defer
  data = ${lookup{$local_part}lsearch{/etc/aliases}}
  file_transport = address_file

domain_aliases:
  debug_print = "R: domain_aliases for $local_part@$domain"
  driver = redirect
  domains = +local_domains
  allow_fail
  allow_defer
  data = ${lookup{$local_part}wildlsearch{/etc/exim4/aliases/$domain}}
  require_files = /etc/exim4/aliases/$domain

dspam_spam:
  driver = accept
  check_local_user
  domains = +local_domains
  local_parts = brettp
  local_part_suffix = -addspam
  transport = dspam_addspam

dspam_ham:
  driver = accept
  check_local_user
  domains = +local_domains
  local_parts = brettp
  local_part_suffix = -addham
  transport = dspam_addham

dspam_filter:
  check_local_user
  local_parts = brettp
  domains = +local_domains
  condition = ${if eq {$received_protocol}{spam-scanned} {no}{yes}}
  driver = accept
  transport = dspam_check

userforward:
  debug_print = "R: userforward for $local_part@$domain"
  driver = redirect
  domains = +local_domains
  check_local_user
  file = $home/.forward
  no_verify
  no_expn
  check_ancestor
  allow_filter
  directory_transport = address_directory
  file_transport = address_file
  pipe_transport = address_pipe
  reply_transport = address_reply
  skip_syntax_errors
  syntax_errors_to = real-$local_part@$domain
  syntax_errors_text = \
    This is an automatically generated message. An error has\n\
    been found in your .forward file. Details of the error are\n\
    reported below. While this error persists, you will receive\n\
    a copy of this message for every message that is addressed\n\
    to you. If your .forward file is a filter file, or if it is\n\
    a non-filter file containing no valid forwarding addresses,\n\
    a copy of each incoming message will be put in your normal\n\
    mailbox. If a non-filter file contains at least one valid\n\
    forwarding address, forwarding to the valid addresses will\n\
    happen, and those will be the only deliveries that occur.

local_user:
  debug_print = "R: local_user for $local_part@$domain"
  driver = accept
  domains = +local_domains
  check_local_user
  local_parts = ! root
  transport = LOCAL_DELIVERY

mail4root:
  debug_print = "R: mail4root for $local_part@$domain"
  driver = redirect
  domains = +local_domains
  data = /var/mail/mail
  file_transport = address_file
  local_parts = root
  user = mail
  group = mail

begin transports

address_file:
  debug_print = "T: address_file for $local_part@$domain"
  driver = appendfile
  delivery_date_add
  envelope_to_add
  return_path_add

address_pipe:
  debug_print = "T: address_pipe for $local_part@$domain"
  driver = pipe
  return_fail_output

address_reply:
  debug_print = "T: autoreply for $local_part@$domain"
  driver = autoreply

maildir_home:
  debug_print = "T: maildir_home for $local_part@$domain"
  driver = appendfile
  directory = $home/Maildir
  delivery_date_add
  envelope_to_add
  return_path_add
  maildir_format
  mode = 0600
  mode_fail_narrower = false

remote_smtp:
  debug_print = "T: remote_smtp for $local_part@$domain"
  driver = smtp

address_directory:
  debug_print = "T: address_directory for $local_part@$domain"
  driver = appendfile
  envelope_to_add = true
  return_path_add = true
  check_string = ""
  escape_string = ""
  maildir_format

dspam_check:
  driver = pipe
  command = /usr/sbin/exim4 -oMr spam-scanned -or 20m -os 20m -bS
  transport_filter =/usr/bin/dspam --mode=teft --deliver=innocent,spam --user $local_part --stdout
  current_directory = "/var/spool/dspam"
  home_directory = "/var/spool/dspam"
  group = dspam
  user = Debian-exim
  log_output
  use_bsmtp
  return_fail_output
  no_return_path_add

dspam_addspam:
  driver = pipe
  command = /usr/sbin/exim4 -oMr spam-scanned -or 20m -os 20m -bS
  transport_filter = /usr/bin/dspam --user $local_part --mode=teft --class=spam --source=error --deliver=summary --stdout
  current_directory = "/var/spool/dspam"
  home_directory = "/var/spool/dspam"
  group = dspam
  user = Debian-exim
  log_output
  use_bsmtp
  return_fail_output
  no_return_path_add

dspam_addham:
  driver = pipe
  command = /usr/sbin/exim4 -oMr spam-scanned -or 20m -os 20m -bS
  transport_filter = /usr/bin/dspam --user = $local_part --mode=teft --class=innocent --source=error --deliver=summary --stdout
  current_directory = "/var/spool/dspam"
  home_directory = "/var/spool/dspam"
  group = dspam
  user = Debian-exim
  log_output
  use_bsmtp
  return_fail_output
  no_return_path_add

begin retry

*                      *           F,2h,15m; G,16h,1h,1.5; F,4d,6h

begin rewrite

*@+local_domains ${lookup{${local_part}}lsearch{/etc/email-addresses}\
                 {$value}fail} Ffrs

*@+local_domains "${if exists {CONFDIR/email-addresses}\
                    {${lookup{${local_part}}lsearch{CONFDIR/email-addresses}\
        {$value}fail}}fail}" Ffrs

begin authenticators

cram_md5:
  driver = cram_md5
  public_name = CRAM-MD5
  client_name = ${extract{1}{:}{${lookup{$host}lsearch*{CONFDIR/passwd.client}{$value}fail}}}
  client_secret = ${extract{2}{:}{${lookup{$host}lsearch*{CONFDIR/passwd.client}{$value}fail}}}

plain:
  driver = plaintext
  public_name = PLAIN
  client_send = "${if !eq{$tls_cipher}{}{\
                      ^${extract{1}{::}\
                      {${lookup{$host}lsearch*{CONFDIR/passwd.client}{$value}fail}}}\
                      ^${extract{2}{::}\
                      {${lookup{$host}lsearch*{CONFDIR/passwd.client}{$value}fail}}}\
                      }fail}"

login:
  driver = plaintext
  public_name = LOGIN
  server_prompts = Username:: : Password::
  server_condition = ${if saslauthd{{$1}{${sg{$2}{:}{::}}}}{yes}{no}}
  client_send = "${if !eq{$tls_cipher}{}{}fail}\
                      : ${extract{1}{::}\
                      {${lookup{$host}lsearch*{CONFDIR/passwd.client}{$value}fail}}}\
                      : ${extract{2}{::}\
                      {${lookup{$host}lsearch*{CONFDIR/passwd.client}{$value}fail}}}"

