# Exim test configuration 3400

.include DIR/aux-var/std_conf_prefix

primary_hostname = myhost.test.ex

# ----- Main settings -----

domainlist local_domains = test.ex : *.test.ex

hostlist auth_hosts = 10.0.0.1
hostlist relay_hosts = 10.0.0.4
hostlist auth_relay_hosts = 10.0.0.3 : 10.0.0.4

acl_smtp_connect = check_connect
acl_smtp_etrn = check_etrn
acl_smtp_expn = check_expn
acl_smtp_rcpt = check_recipient
acl_smtp_vrfy = check_vrfy
auth_advertise_hosts = +auth_hosts : !+relay_hosts : +auth_relay_hosts : \
                       10.0.0.5
smtp_accept_max_nonmail = 20
system_filter = DIR/aux-fixed/TESTNUM.filter
trusted_users = CALLER


# ----- ACL -----

begin acl

check_connect:
  warn     hosts = 10.0.0.6
           control = allow_auth_unadvertised
  accept

check_recipient:
  warn     hosts = 10.0.0.5
           message = authentication-failed: $authentication_failed
  accept   hosts = 10.0.0.5
  accept   hosts = :
  deny     hosts = +auth_hosts
           message = authentication required
          !authenticated = *
  accept   domains = +local_domains
  accept   hosts = +relay_hosts
  accept   hosts = +auth_relay_hosts
           endpass
           message = authentication required
           authenticated = *
  deny     message = relay not permitted

check_etrn:
  deny     hosts = +auth_hosts
           message = authentication required
          !authenticated = *
  require  hosts = 10.0.0.0/24
  warn     log_message = accepted ETRN $smtp_command_argument
  accept

check_expn:
  deny     hosts = +auth_hosts
           message = authentication required
          !authenticated = *
  accept   hosts = 10.0.0.0/24

check_vrfy:
  deny     hosts = +auth_hosts
           message = authentication required
          !authenticated = *
  accept


# ----- Authentication -----

begin authenticators

mylogin:
  driver = plaintext
  public_name = mylogin
  server_debug_print = +++MYLOGIN \$1="$1" \$2=\"$2" \$3="$3"
  server_condition = "\
    ${if match{$1}{^(\\\\S+)\\\\s+(\\\\S+)\\$}\
    {${if and {{eq{$1}{userx}}{eq{$2}{secret}}}{yes}{no}}}{no}}"

plain:
  driver = plaintext
  public_name = PLAIN
  server_condition = "\
    ${if and {{eq{$auth2}{userx}}{eq{$auth3}{secret}}}{yes}{no}}"
  server_set_id = $auth2

extended_plain:
  driver = plaintext
  public_name = EXPLAIN
  server_prompts = :
  server_condition = "\
    ${if and {{eq{$auth2}{userx}}{eq{$auth3}{secret}}}{yes}{no}}"
  server_set_id = $auth2

expanded_prompt_plain:
  driver = plaintext
  public_name = EXPANDED
  server_prompts = $primary_hostname
  server_condition = "\
    ${if and {{eq{$auth2}{userx}}{eq{$auth3}{secret}}}{yes}{no}}"
  server_set_id = $auth2

expanded_prompt_plain_fail:
  driver = plaintext
  public_name = EXPANDFAIL
  server_prompts = $nonexistent
  server_condition = "\
    ${if and {{eq{$auth2}{userx}}{eq{$auth3}{secret}}}{yes}{no}}"
  server_set_id = $auth2

defer:
  driver = plaintext
  public_name = DEFER
  server_condition = "account suspended"
  server_set_id = $auth2

login:
  driver = plaintext
  public_name = LOGIN
  server_prompts = "User Name : Password "
  server_condition = "\
    ${if and {{eq{$auth1}{userx}}{eq{$auth2}{secret}}}{yes}{no}}"
  server_set_id = $auth1


# ----- Routers -----

begin routers

fail_remote_domains:
  driver = redirect
  domains = ! +local_domains
  data = :fail: unrouteable mail domain "$domain"

localuser:
  driver = accept
  local_parts = userx
  transport = appendfile


# ----- Transports -----

begin transports

appendfile:
  driver = appendfile
  delivery_date_add
  envelope_to_add
  file = DIR/test-mail/$local_part
  return_path_add
  user = CALLER


# End