# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 2 on
# fresh installs.
compatibility_level = 2

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/fullchain.pem
smtpd_tls_key_file=/etc/ssl/certs/privkey.pem
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_tls_loglevel=1
smtpd_tls_received_header=yes
smtp_use_tls=yes
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

mydomain = {{ salt['pillar.get']("model:common:mail:domain") }}
myhostname = {{ salt['pillar.get']("model:common:mail:host") }}
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
message_size_limit = 0
recipient_delimiter = +

recipient_bcc_maps = pgsql:/etc/postfix/pgsql_recipient_bcc.cf
transport_maps = pgsql:/etc/postfix/pgsql_transport.cf
virtual_mailbox_domains = pgsql:/etc/postfix/pgsql_virtual_mailbox_domains.cf
virtual_mailbox_maps = pgsql:/etc/postfix/pgsql_virtual_mailbox_maps.cf
virtual_alias_maps = pgsql:/etc/postfix/pgsql_virtual_alias_maps.cf,
                     pgsql:/etc/postfix/pgsql_virtual_alias_maps_regexp.cf,
                     pgsql:/etc/postfix/pgsql_virtual_alias_domain_maps.cf,
                     pgsql:/etc/postfix/pgsql_virtual_alias_maps_alias.cf
relay_domains = pgsql:/etc/postfix/pgsql_relay_domains.cf
virtual_uid_maps=static:7788
virtual_gid_maps=static:7788
virtual_transport=lmtp:inet:{{ salt['pillar.get']("model:dovecot:host") }}:{{ salt['pillar.get']("model:dovecot:lmtp:port") }}
dovecot_destination_recipient_limit = 1


smtpd_sasl_type=dovecot
smtpd_sasl_path=inet:{{ salt['pillar.get']("model:dovecot:host") }}:{{ salt['pillar.get']("model:dovecot:sasl:port") }}
smtpd_sasl_auth_enable=yes
smtpd_sasl_local_domain=$myhostname
smtpd_helo_required=yes
smtpd_helo_restrictions=reject_invalid_helo_hostname
smtpd_recipient_restrictions=permit_mynetworks,
        permit_sasl_authenticated,
        reject_unknown_recipient_domain,
        reject_unauth_pipelining,
        reject_unauth_destination


milter_default_action = accept
smtpd_milters = inet:{{ salt['pillar.get']("model:milterSasl:host") }}:{{ salt['pillar.get']("model:milterSasl:port") }},
                inet:{{ salt['pillar.get']("model:opendkim:host") }}:{{ salt['pillar.get']("model:opendkim:port") }}
non_smtpd_milters = inet:{{ salt['pillar.get']("model:opendkim:host") }}:{{ salt['pillar.get']("model:opendkim:port") }}
smtpd_relay_restrictions = permit_mynetworks,
        permit_sasl_authenticated,
        reject_unknown_recipient_domain,
        reject_unauth_pipelining,
        reject_unauth_destination
