exim4.conf.template 11 KB

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