97f07bdf4ce598c5c4329ffd2a301c301a2a3740
[ansible.git] / roles / email / templates / main.cf
1 compatibility_level = 2
2
3 # local delivery: aliases only
4 alias_maps = hash:/etc/aliases
5 local_recipient_maps = $alias_maps
6 {% if postfix.mynetworks is defined %}
7 mynetworks = {{ postfix.mynetworks }}
8 {% endif %}
9
10 # TLS server parameters
11 smtpd_tls_cert_file=/etc/ssl/mycerts/letsencrypt/live.crt+chain
12 smtpd_tls_key_file=/etc/ssl/private/letsencrypt/live.key
13 smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
14 smtpd_tls_security_level = may
15 smtpd_tls_loglevel = 1
16 smtpd_tls_dh1024_param_file = /etc/ssl/dh2048.pem
17 smtpd_tls_mandatory_protocols = !SSLv2 !SSLv3
18 smtpd_tls_ciphers = low
19 smtpd_tls_mandatory_ciphers = high
20 # TLS client parameters
21 smtp_tls_mandatory_protocols = !SSLv2 !SSLv3
22 smtp_tls_ciphers = low
23 smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
24 smtp_tls_loglevel = 1
25 {% if not(postfix.relay_host is defined) %}
26 smtp_tls_security_level = dane
27 smtp_dns_support_level = dnssec
28 {% endif %}
29
30 {% if postfix.postscreen | default(False) %}
31 # postscreen config
32 postscreen_dnsbl_threshold = 3
33 postscreen_dnsbl_whitelist_threshold = -2
34 postscreen_dnsbl_sites =
35         ix.dnsbl.manitu.net*2 sbl-xbl.spamhaus.org*2
36         bl.spamcop.net dnsbl.sorbs.net bl.mailspike.net
37         swl.spamhaus.org*-2 list.dnswl.org=127.0.[0..255].[0..254]*-2
38 postscreen_greet_action = enforce
39 postscreen_dnsbl_action = enforce
40 postscreen_pipelining_enable = yes
41 postscreen_non_smtp_command_enable = yes
42 postscreen_bare_newline_enable = yes
43 {% endif %}
44
45 # control relay access
46 smtpd_relay_restrictions = permit_mynetworks, permit_tls_clientcerts,
47     # allow nobody else
48     defer_unauth_destination
49 # spam-protection restrictions
50 smtpd_helo_required = yes
51 smtpd_recipient_restrictions = permit_mynetworks, permit_tls_clientcerts,
52     # check everybody else
53     reject_unauth_pipelining,
54     reject_invalid_helo_hostname,
55     reject_non_fqdn_recipient,
56     reject_non_fqdn_sender,
57
58 {% if postfix.relay_host is defined %}
59 # Relay everything
60 default_transport = smtp:{{ postfix.relay_host }}
61 {% if postfix.relay_client_cert is defined %}
62 # Enforce relay encryption
63 smtp_tls_cert_file=$config_directory/{{ postfix.relay_client_cert }}.crt
64 smtp_tls_key_file=$config_directory/{{ postfix.relay_client_cert }}.key
65 smtp_tls_security_level = encrypt
66 {% endif %}
67 {% endif %}
68
69 {% if postfix.submission | default(False) %}
70 # configure SASL
71 smtpd_sasl_type = dovecot
72 smtpd_sasl_path = private/auth
73 {% endif %}
74
75 {% if postfix.relay_client_cert_whitelist is defined %}
76 # allow relay for some TLS-authenticated clients
77 smtpd_tls_ask_ccert = yes
78 smtpd_tls_fingerprint_digest = sha1
79 relay_clientcerts = hash:$config_directory/relay_clientcerts
80 {% endif %}
81
82 {% if postfix.virtual_mailbox_domains is defined %}
83 # setup virtual delivery domains, aliases and destinations
84 virtual_mailbox_domains ={% for item in postfix.virtual_mailbox_domains %} {{item.domain}}{% endfor %}
85
86 virtual_alias_maps = hash:$config_directory/virtual_alias_map
87   {% if postfix.dovecot is defined %}
88   proxy:mysql:$config_directory/mysql_vmail_aliases.cf
89   {% endif %}
90
91 virtual_mailbox_maps =
92   {% if postfix.dovecot is defined %}
93   proxy:mysql:$config_directory/mysql_vmail_users.cf
94   {% endif %}
95   {% if postfix.mailman | default(False) %}
96   hash:/var/lib/mailman/data/virtual-mailman
97   {% endif %}
98
99 smtpd_sender_login_maps =
100   {% if postfix.dovecot is defined %}
101   proxy:mysql:$config_directory/mysql_vmail_users.cf
102   proxy:mysql:$config_directory/mysql_vmail_senders.cf
103   proxy:mysql:$config_directory/mysql_vmail_aliases.cf
104   {% endif %}
105
106 proxy_read_maps = $virtual_alias_maps $virtual_mailbox_maps $smtpd_sender_login_maps
107
108 # setup mail routes for virtual mail: all mail ends up being forwarded somewhere
109 virtual_transport = error
110 transport_maps = hash:/etc/postfix/transport_map
111 mailman_destination_recipient_limit = 1
112 {% endif %}
113
114 {% if postfix.smtp_outgoing is defined %}
115 default_transport = {{ postfix.default_smtp_outgoing }}
116 sender_dependent_default_transport_maps = hash:$config_directory/sender_transport_map
117 {% endif %}
118
119 {% if postfix.opendkim is defined %}
120 # DKIM & Milter
121 milter_default_action = accept
122 # Path must match opendkim.env
123 smtpd_milters = unix:opendkim/sock
124 non_smtpd_milters = $smtpd_milters
125 {% endif %}
126
127 # misc
128 smtpd_delay_reject = yes
129 disable_vrfy_command = yes
130 recipient_delimiter = +
131 delay_warning_time = 4h
132 message_size_limit = 21384000