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