# This transport is used for delivering messages over SMTP connections.

#
# This constant is used to validate DKIM selectors.
#
DKIM_SELECTOR_REGEX = (?i)\N\b(([_a-z0-9-]+)(\.[_a-z0-9-]+)*)\b\N

remote_smtp_with_dkim:
  debug_print = "T: remote_smtp_with_dkim for $local_part@$domain ($sender_address_domain key)"
  driver = smtp
  #
  # Sign using the $sender_address_domain
  #
  dkim_domain      = $sender_address_domain

  #
  # This reads the dkim selector file in, replaces new lines with colons, and
  # picks the first.  If it is empty, use the $primary_hostname.
  #
  dkim_selector = ${if match{ ${readfile{VHOST_DIR/${sender_address_domain}/VHOST_CONFIG_DIR/dkim}} }\
                       {DKIM_SELECTOR_REGEX}\
                       {$1}\
                       {${if match{$primary_hostname}\
                              {DKIM_SELECTOR_REGEX}\
                              {$2}\
                              {default}\
                       }}\
                  }

  dkim_private_key = ${readfile{VHOST_DIR/${sender_address_domain}/VHOST_CONFIG_DIR/dkim.key}}

  #
  # If dkim_strict is set to true, exim will defer sending the message if
  # signing fails for some reason, otherwise it will send it unsigned.
  #
  # dkim_strict =

  # 
  # The DKIM RFC currently supports two methods: "simple" and "relaxed". The
  # option defaults to "relaxed" when unset.
  #
  # dkim_canon = 
  
  # 
  # When unspecified, the header names recommended in RFC4871 will be used. 
  #
  # dkim_sign_headers =
  #

  # 
  # Use the domain's IP (if it has one) to send outgoing mail.  We use
  # $sender_address_domain, or a default value kept in
  # /etc/sympl/config/ip(s).
  #
  interface = <, ${extract {1}{:}\
      {${filter\
        {VHOST_DIR/$sender_address_domain/config/ip:VHOST_DIR/$sender_address_domain/config/ips:/etc/sympl/config/ip:/etc/sympl/config/ips}\
        {exists{$item}}\
      }}\
      {${if !eq{$value}{}{\
        ${filter\
          {<,${readfile{$value}}}\
          {isip{$item}}\
        }}\
      }}\
    }
 
