1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#
# Directories
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/lib/postfix
data_directory = /var/lib/postfix
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /etc/postfix/sample
readme_directory = no


#
# Paths
sendmail_path = /usr/sbin/sendmail
newaliases_path = /usr/bin/newaliases
mailq_path = /usr/bin/mailq


#
# Permissions
mail_owner = postfix
default_privs = nobody
setgid_group = postdrop


#
# Network Settings
myhostname = mx1.mailgate.se
mydomain = mailgate.se
myorigin = $myhostname
inet_protocols = all
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost
mynetworks = 127.0.0.0/8


#
# Virtual Settings
virtual_mailbox_domains = proxy:mysql:/etc/postfix/virtual_domains_mysql.cf
virtual_mailbox_base = /home/mailboxes
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mailbox_mysql.cf
virtual_minimum_uid = 100
virtual_uid_maps = static:500
virtual_gid_maps = static:500
virtual_alias_maps = proxy:mysql:/etc/postfix/aliases_mysql.cf
virtual_destination_concurrency_limit = 5
virtual_transport = dovecot


#
# Pipe Settings
dovecot_destination_recipient_limit = 1


#
# Transport Settings
transport_maps = proxy:mysql:/etc/postfix/transport_mysql.cf


#
# Relay Settings
relay_recipient_maps = proxy:mysql:/etc/postfix/relay_recipient_mysql.cf
relay_domains = proxy:mysql:/etc/postfix/relay_domains_mysql.cf


#
# Postscreen Settings
postscreen_access_list = permit_mynetworks,
    cidr:/etc/postfix/postscreen_access_whitelist.cidr,
    cidr:/etc/postfix/postscreen_access_blacklist.cidr
postscreen_dnsbl_threshold = 4
postscreen_dnsbl_sites =
    list.dnswl.org=127.0.[0..255].3*-7,
    list.dnswl.org=127.0.[0..255].2*-4,
    list.dnswl.org=127.0.[0..255].1*-1,
    zen.spamhaus.org=127.0.0.2*3,
    zen.spamhaus.org=127.0.0.3*3,
    bl.mailspike.net=127.0.0.2*3,
    bl.mailspike.net=127.0.0.10*3,
    b.barracudacentral.org*3,
    zen.spamhaus.org=127.0.0.[4..8]*2,
    zen.spamhaus.org=127.0.0.[10..11]*2,
    bl.mailspike.net=127.0.0.[11..12]*2,
    bl.spameatingmonkey.net*2,
    psbl.surriel.com*2,
    dnsbl.njabl.org*2,
    dnsbl.ahbl.org*2,
    backscatter.spameatingmonkey.net*1,
    dnsbl.sorbs.net*1,
    bl.spamcop.net*1

postscreen_dnsbl_action = drop
postscreen_dnsbl_ttl = 1d
postscreen_helo_required = yes
postscreen_blacklist_action = drop
postscreen_cache_cleanup_interval = 12h
postscreen_cache_retention_time = 7d
postscreen_client_connection_count_limit = 25
postscreen_command_count_limit = 20
postscreen_command_time_limit = ${stress?10}${stress:60}s
postscreen_greet_action = drop
postscreen_greet_ttl = 3d
postscreen_greet_wait = ${stress?3}${stress:7}s


#
# Postscreen deep protocol tests.
postscreen_non_smtp_command_enable = no
postscreen_bare_newline_enable = no
postscreen_pipelining_enable = no
postscreen_non_smtp_command_action = ignore
postscreen_bare_newline_action = ignore
postscreen_pipelining_action = ignore
postscreen_non_smtp_command_ttl = 30d
postscreen_bare_newline_ttl = 30d
postscreen_pipelining_ttl = 30d


#
# Misc/Security Settings
smtpd_banner = $myhostname
anvil_rate_time_unit = 30s
smtpd_timeout = 30s
smtpd_soft_error_limit = 2
smtpd_hard_error_limit = 5
smtpd_error_sleep_time = 10s
smtpd_junk_command_limit = 5
show_user_unknown_table_name = no
disable_vrfy_command = yes
alias_maps = hash:/etc/postfix/aliases

#
# Handle 25MB mails
message_size_limit = 26214400
mailbox_size_limit = 52428800
virtual_mailbox_limit = 52428800


#
# Content Filtering
header_checks = pcre:/etc/postfix/header_checks.pcre
body_checks = pcre:/etc/postfix/body_checks.pcre


#
# Milters
smtpd_milters = inet:127.0.0.1:8891

#
# SASL Authentication
smtpd_sasl_auth_enable = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth


#
# Connection/Spam Throttling
in_flow_delay = 1s
anvil_rate_time_unit = 60s
smtp_connect_timeout = 30s
smtp_helo_timeout = 300s
smtp_mail_timeout = 300s
smtp_rcpt_timeout = 300s
smtp_quit_timeout = 30s
smtpd_recipient_limit = 1000
smtpd_client_connection_count_limit = 50
smtpd_client_connection_rate_limit = 1000
smtpd_client_message_rate_limit = 0
smtpd_client_recipient_rate_limit = 0
smtpd_client_new_tls_session_rate_limit = 250
smtpd_client_event_limit_exceptions = $mynetworks


#
# Smtpd Restrictions
smtpd_helo_required = yes
strict_rfc821_envelopes = no
spf_time_limit = 3600s

smtpd_recipient_restrictions =
    permit_mynetworks,
    permit_inet_interfaces,
    permit_sasl_authenticated,
    reject_invalid_helo_hostname,
    reject_non_fqdn_helo_hostname,
    #reject_unknown_helo_hostname,
    reject_unauth_destination,
    reject_unauth_pipelining,
    reject_non_fqdn_sender,
    reject_non_fqdn_recipient,
    check_policy_service unix:private/spf,
    reject_unknown_sender_domain,
    reject_unknown_recipient_domain,
    check_helo_access hash:/etc/postfix/helo_checks,
    check_client_access hash:/etc/postfix/client_checks,
    check_sender_access hash:/etc/postfix/sender_checks,
    check_recipient_access pcre:/etc/postfix/recipient_checks.pcre,
    check_policy_service unix:private/postgrey,
    permit


#
# TLS/SSL
smtp_use_tls = yes
smtpd_use_tls = yes
smtp_tls_note_starttls_offer = yes
smtpd_tls_key_file = /etc/postfix/key.pem
smtpd_tls_cert_file = /etc/postfix/cert.pem
smtpd_tls_CAfile = /etc/postfix/cacert.pem
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 900s
tls_random_source = dev:/dev/urandom