exim4.conf.template 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. ######################################################################
  2. # #
  3. # Exim configuration file for Hestia Control Panel #
  4. # #
  5. ######################################################################
  6. #SPAMASSASSIN = yes
  7. #SPAM_SCORE = 50
  8. #CLAMD = yes
  9. smtp_banner = $smtp_active_hostname
  10. add_environment = <; PATH=/bin:/usr/bin
  11. keep_environment =
  12. disable_ipv6 = true
  13. domainlist local_domains = dsearch;/etc/exim4/domains/
  14. domainlist relay_to_domains = dsearch;/etc/exim4/domains/
  15. hostlist relay_from_hosts = 127.0.0.1
  16. hostlist whitelist = net-iplsearch;/etc/exim4/white-blocks.conf
  17. hostlist spammers = net-iplsearch;/etc/exim4/spam-blocks.conf
  18. no_local_from_check
  19. untrusted_set_sender = *
  20. acl_smtp_connect = acl_check_spammers
  21. acl_smtp_mail = acl_check_mail
  22. acl_smtp_rcpt = acl_check_rcpt
  23. acl_smtp_data = acl_check_data
  24. acl_smtp_mime = acl_check_mime
  25. .ifdef SPAMASSASSIN
  26. spamd_address = 127.0.0.1 783
  27. .endif
  28. .ifdef CLAMD
  29. av_scanner = clamd: /var/run/clamav/clamd.ctl
  30. .endif
  31. log_selector = +tls_sni
  32. tls_advertise_hosts = *
  33. # We test that $tls_in_sni is a valid domain, by an arbitrary email address foo@domain.tld .
  34. # Then, we extract the domain with a function that would fail if the email address is invalid.
  35. # If the certificate exists, we will use it, otherwise the default certificate in /etc/ssl will be used.
  36. tls_certificate = \
  37. ${if and {\
  38. { eq {${domain:foo@$tls_in_sni}} {$tls_in_sni}}\
  39. { exists{/usr/local/hestia/ssl/mail/$tls_in_sni.crt} }\
  40. }\
  41. {/usr/local/hestia/ssl/mail/$tls_in_sni.crt}\
  42. {/usr/local/hestia/ssl/certificate.crt}\
  43. }
  44. tls_privatekey = \
  45. ${if and {\
  46. { eq {${domain:foo@$tls_in_sni}} {$tls_in_sni}}\
  47. { exists{/usr/local/hestia/ssl/mail/$tls_in_sni.key} }\
  48. }\
  49. {/usr/local/hestia/ssl/mail/$tls_in_sni.key}\
  50. {/usr/local/hestia/ssl/certificate.key}\
  51. }
  52. daemon_smtp_ports = 25 : 465 : 587
  53. tls_on_connect_ports = 465
  54. never_users = root
  55. host_lookup = *
  56. rfc1413_hosts = *
  57. rfc1413_query_timeout = 5s
  58. ignore_bounce_errors_after = 2d
  59. timeout_frozen_after = 7d
  60. DKIM_DOMAIN = ${lc:${domain:$h_from:}}
  61. DKIM_FILE = /etc/exim4/domains/${lc:${domain:$h_from:}}/dkim.pem
  62. DKIM_PRIVATE_KEY = ${if exists{DKIM_FILE}{DKIM_FILE}{0}}
  63. ######################################################################
  64. # ACL CONFIGURATION #
  65. # Specifies access control lists for incoming SMTP mail #
  66. ######################################################################
  67. acl_not_smtp = acl_not_smtp
  68. begin acl
  69. # Limit per user for PHP scripts
  70. acl_not_smtp:
  71. deny message = Website of user $authenticated_id is sending too many emails - rate overlimit = $sender_rate / $sender_rate_period
  72. ratelimit = 200 / 1h / $authenticated_id
  73. warn ratelimit = 100 / 1h / strict / $authenticated_id
  74. log_message = Sender rate [limitlog]: log / account / $authenticated_id / $sender_rate / $sender_rate_period
  75. accept
  76. acl_check_spammers:
  77. accept hosts = +whitelist
  78. drop message = Your host in blacklist on this server.
  79. log_message = Host in blacklist
  80. hosts = +spammers
  81. accept
  82. acl_check_mail:
  83. deny condition = ${if eq{$sender_helo_name}{}}
  84. message = HELO required before MAIL
  85. drop message = Helo name contains an IP address (HELO was $sender_helo_name) and not is valid
  86. condition = ${if match{$sender_helo_name}{\N((\d{1,3}[.-]\d{1,3}[.-]\d{1,3}[.-]\d{1,3})|([0-9a-f]{8})|([0-9A-F]{8}))\N}{yes}{no}}
  87. condition = ${if match {${lookup dnsdb{>: defer_never,ptr=$sender_host_address}}\}{$sender_helo_name}{no}{yes}}
  88. delay = 45s
  89. drop condition = ${if isip{$sender_helo_name}}
  90. message = Access denied - Invalid HELO name (See RFC2821 4.1.3)
  91. drop condition = ${if eq{[$interface_address]}{$sender_helo_name}}
  92. message = $interface_address is _my_ address
  93. accept
  94. acl_check_rcpt:
  95. accept hosts = :
  96. # Limit per email account for SMTP auhenticated users
  97. deny message = Email account $authenticated_id is sending too many emails - rate overlimit = $sender_rate / $sender_rate_period
  98. ratelimit = 200 / 1h / $authenticated_id
  99. warn ratelimit = 100 / 1h / strict / $authenticated_id
  100. log_message = Sender rate [limitlog]: log / email / $authenticated_id / $sender_rate / $sender_rate_period
  101. deny message = Restricted characters in address
  102. domains = +local_domains
  103. local_parts = ^[.] : ^.*[@%!/|]
  104. deny message = Restricted characters in address
  105. domains = !+local_domains
  106. local_parts = ^[./|] : ^.*[@%!] : ^.*/\\.\\./
  107. require verify = sender
  108. accept hosts = +relay_from_hosts
  109. control = submission
  110. accept authenticated = *
  111. control = submission/domain=
  112. deny message = Rejected because $sender_host_address is in a black list at $dnslist_domain\n$dnslist_text
  113. hosts = !+whitelist
  114. dnslists = ${readfile {/etc/exim4/dnsbl.conf}{:}}
  115. require message = relay not permitted
  116. domains = +local_domains : +relay_to_domains
  117. deny message = smtp auth required
  118. sender_domains = +local_domains
  119. !authenticated = *
  120. require verify = recipient
  121. .ifdef CLAMD
  122. warn set acl_m0 = no
  123. warn condition = ${if exists {/etc/exim4/domains/$domain/antivirus}{yes}{no}}
  124. set acl_m0 = yes
  125. .endif
  126. .ifdef SPAMASSASSIN
  127. warn set acl_m1 = no
  128. warn condition = ${if exists {/etc/exim4/domains/$domain/antispam}{yes}{no}}
  129. set acl_m1 = yes
  130. .endif
  131. accept
  132. acl_check_data:
  133. .ifdef CLAMD
  134. deny message = Message contains a virus ($malware_name) and has been rejected
  135. malware = */defer_ok
  136. condition = ${if eq{$acl_m0}{yes}{yes}{no}}
  137. .endif
  138. .ifdef SPAMASSASSIN
  139. warn !authenticated = *
  140. hosts = !+relay_from_hosts
  141. condition = ${if < {$message_size}{1024K}}
  142. condition = ${if eq{$acl_m1}{yes}{yes}{no}}
  143. spam = debian-spamd:true/defer_ok
  144. add_header = X-Spam-Score: $spam_score_int
  145. add_header = X-Spam-Bar: $spam_bar
  146. add_header = X-Spam-Report: $spam_report
  147. set acl_m2 = $spam_score_int
  148. warn condition = ${if !eq{$acl_m2}{} {yes}{no}}
  149. condition = ${if >{$acl_m2}{SPAM_SCORE} {yes}{no}}
  150. add_header = X-Spam-Status: Yes
  151. message = SpamAssassin detected spam (from $sender_address to $recipients).
  152. .endif
  153. accept
  154. acl_check_mime:
  155. deny message = Blacklisted file extension detected
  156. condition = ${if match {${lc:$mime_filename}}{\N(\.ade|\.adp|\.bat|\.chm|\.cmd|\.com|\.cpl|\.exe|\.hta|\.ins|\.isp|\.jse|\.lib|\.lnk|\.mde|\.msc|\.msp|\.mst|\.pif|\.scr|\.sct|\.shb|\.sys|\.vb|\.vbe|\.vbs|\.vxd|\.wsc|\.wsf|\.wsh)$\N}{1}{0}}
  157. accept
  158. ######################################################################
  159. # AUTHENTICATION CONFIGURATION #
  160. ######################################################################
  161. begin authenticators
  162. dovecot_plain:
  163. driver = dovecot
  164. public_name = PLAIN
  165. server_socket = /var/run/dovecot/auth-client
  166. server_set_id = $auth1
  167. dovecot_login:
  168. driver = dovecot
  169. public_name = LOGIN
  170. server_socket = /var/run/dovecot/auth-client
  171. server_set_id = $auth1
  172. ######################################################################
  173. # ROUTERS CONFIGURATION #
  174. # Specifies how addresses are handled #
  175. ######################################################################
  176. begin routers
  177. #smarthost:
  178. # driver = manualroute
  179. # domains = ! +local_domains
  180. # transport = remote_smtp
  181. # route_list = * smartrelay.hestiacp.com
  182. # no_more
  183. # no_verify
  184. dnslookup:
  185. driver = dnslookup
  186. domains = !+local_domains
  187. transport = remote_smtp
  188. no_more
  189. userforward:
  190. driver = redirect
  191. check_local_user
  192. file = $home/.forward
  193. allow_filter
  194. no_verify
  195. no_expn
  196. check_ancestor
  197. file_transport = address_file
  198. pipe_transport = address_pipe
  199. reply_transport = address_reply
  200. procmail:
  201. driver = accept
  202. check_local_user
  203. require_files = ${local_part}:+${home}/.procmailrc:/usr/bin/procmail
  204. transport = procmail
  205. no_verify
  206. autoreplay:
  207. driver = accept
  208. require_files = /etc/exim4/domains/$domain/autoreply.${local_part}.msg
  209. condition = ${if exists{/etc/exim4/domains/$domain/autoreply.${local_part}.msg}{yes}{no}}
  210. retry_use_local_part
  211. transport = userautoreply
  212. unseen
  213. aliases:
  214. driver = redirect
  215. headers_add = X-redirected: yes
  216. data = ${extract{1}{:}{${lookup{$local_part@$domain}lsearch{/etc/exim4/domains/$domain/aliases}}}}
  217. require_files = /etc/exim4/domains/$domain/aliases
  218. redirect_router = dnslookup
  219. pipe_transport = address_pipe
  220. unseen
  221. localuser_fwd_only:
  222. driver = accept
  223. transport = devnull
  224. condition = ${if exists{/etc/exim4/domains/$domain/fwd_only}{${lookup{$local_part}lsearch{/etc/exim4/domains/$domain/fwd_only}{true}{false}}}}
  225. localuser_spam:
  226. driver = accept
  227. transport = local_spam_delivery
  228. condition = ${if eq {${if match{$h_X-Spam-Status:}{\N^Yes\N}{yes}{no}}} {${lookup{$local_part}lsearch{/etc/exim4/domains/$domain/passwd}{yes}{no_such_user}}}}
  229. localuser:
  230. driver = accept
  231. transport = local_delivery
  232. condition = ${lookup{$local_part}lsearch{/etc/exim4/domains/$domain/passwd}{true}{false}}
  233. catchall:
  234. driver = redirect
  235. headers_add = X-redirected: yes
  236. require_files = /etc/exim4/domains/$domain/aliases
  237. data = ${extract{1}{:}{${lookup{*@$domain}lsearch{/etc/exim4/domains/$domain/aliases}}}}
  238. file_transport = local_delivery
  239. redirect_router = dnslookup
  240. terminate_alias:
  241. driver = accept
  242. transport = devnull
  243. condition = ${lookup{$local_part@$domain}lsearch{/etc/exim4/domains/$domain/aliases}{true}{false}}
  244. ######################################################################
  245. # TRANSPORTS CONFIGURATION #
  246. ######################################################################
  247. begin transports
  248. remote_smtp:
  249. driver = smtp
  250. helo_data = mail.${sender_address_domain}
  251. dkim_domain = DKIM_DOMAIN
  252. dkim_selector = mail
  253. dkim_private_key = DKIM_PRIVATE_KEY
  254. dkim_canon = relaxed
  255. dkim_strict = 0
  256. procmail:
  257. driver = pipe
  258. command = "/usr/bin/procmail -d $local_part"
  259. return_path_add
  260. delivery_date_add
  261. envelope_to_add
  262. user = $local_part
  263. initgroups
  264. return_output
  265. local_delivery:
  266. driver = appendfile
  267. maildir_format
  268. maildir_use_size_file
  269. user = ${extract{2}{:}{${lookup{$local_part}lsearch{/etc/exim4/domains/$domain/passwd}}}}
  270. group = mail
  271. create_directory
  272. directory_mode = 770
  273. mode = 660
  274. use_lockfile = no
  275. delivery_date_add
  276. envelope_to_add
  277. return_path_add
  278. directory = "${extract{5}{:}{${lookup{$local_part}lsearch{/etc/exim4/domains/$domain/passwd}}}}/mail/$domain/$local_part"
  279. quota = ${extract{6}{:}{${lookup{$local_part}lsearch{/etc/exim4/domains/$domain/passwd}}}}M
  280. quota_warn_threshold = 75%
  281. local_spam_delivery:
  282. driver = appendfile
  283. maildir_format
  284. maildir_use_size_file
  285. user = ${extract{2}{:}{${lookup{$local_part}lsearch{/etc/exim4/domains/$domain/passwd}}}}
  286. group = mail
  287. create_directory
  288. directory_mode = 770
  289. mode = 660
  290. use_lockfile = no
  291. delivery_date_add
  292. envelope_to_add
  293. return_path_add
  294. directory = "${extract{5}{:}{${lookup{$local_part}lsearch{/etc/exim4/domains/$domain/passwd}}}}/mail/$domain/$local_part/.Spam"
  295. quota = ${extract{6}{:}{${lookup{$local_part}lsearch{/etc/exim4/domains/$domain/passwd}}}}M
  296. quota_directory = "${extract{5}{:}{${lookup{$local_part}lsearch{/etc/exim4/domains/$domain/passwd}}}}/mail/$domain/$local_part"
  297. quota_warn_threshold = 75%
  298. address_pipe:
  299. driver = pipe
  300. return_output
  301. address_file:
  302. driver = appendfile
  303. delivery_date_add
  304. envelope_to_add
  305. return_path_add
  306. address_reply:
  307. driver = autoreply
  308. userautoreply:
  309. driver = autoreply
  310. file = /etc/exim4/domains/$domain/autoreply.${local_part}.msg
  311. from = "${local_part}@${domain}"
  312. headers = Content-Type: text/plain; charset=utf-8;\nContent-Transfer-Encoding: 8bit
  313. subject = "${if def:h_Subject: {Autoreply: \"${rfc2047:$h_Subject:}\"} {Autoreply Message}}"
  314. to = "${sender_address}"
  315. devnull:
  316. driver = appendfile
  317. file = /dev/null
  318. ######################################################################
  319. # RETRY CONFIGURATION #
  320. ######################################################################
  321. begin retry
  322. # Address or Domain Error Retries
  323. # ----------------- ----- -------
  324. * * F,2h,15m; G,16h,1h,1.5; F,4d,6h
  325. ######################################################################
  326. # REWRITE CONFIGURATION #
  327. ######################################################################
  328. begin rewrite
  329. ######################################################################