exim4.conf.template 11 KB

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