exim4.conf.template 12 KB

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