Advertisement
svxvcer

Untitled

Oct 23rd, 2021
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.75 KB | None | 0 0
  1. ######################################################################
  2. #1 #
  3. # Exim configuration file for Hestia Control Panel #
  4. # #
  5. ######################################################################
  6.  
  7. SPAMASSASSIN = yes
  8. SPAM_SCORE = 50
  9. CLAMD = yes
  10.  
  11. #smtp_banner = $smtp_active_hostname
  12. #smtp_active_hostname = ${if exists {/etc/exim4/mailhelo.conf}{${lookup{$interface_address}lsearch{/etc/exim4/mailhelo.conf}{$value}{$primary_hostname}}}{$primary_hostname}}
  13. #рабочий банер
  14. smtp_banner = "${smtp_active_hostname}"
  15. smtp_active_hostname = ${lookup{$interface_address}lsearch{/etc/ip_hostname}{$value}{$primary_hostname}}
  16. add_environment = <; PATH=/bin:/usr/bin
  17. keep_environment =
  18. disable_ipv6 = true
  19.  
  20. domainlist local_domains = dsearch;/etc/exim4/domains/
  21. domainlist relay_to_domains = dsearch;/etc/exim4/domains/
  22. hostlist relay_from_hosts = 127.0.0.1
  23. hostlist whitelist = net-iplsearch;/etc/exim4/white-blocks.conf
  24. hostlist spammers = net-iplsearch;/etc/exim4/spam-blocks.conf
  25. no_local_from_check
  26. untrusted_set_sender = *
  27. acl_smtp_connect = acl_check_spammers
  28. acl_smtp_mail = acl_check_mail
  29. acl_smtp_rcpt = acl_check_rcpt
  30. acl_smtp_data = acl_check_data
  31. acl_smtp_mime = acl_check_mime
  32.  
  33. .ifdef SPAMASSASSIN
  34. spamd_address = 127.0.0.1 783
  35. .endif
  36.  
  37. .ifdef CLAMD
  38. av_scanner = clamd: /var/run/clamav/clamd.ctl
  39. .endif
  40.  
  41. log_selector = +tls_sni
  42.  
  43. tls_advertise_hosts = *
  44.  
  45. # We test that $tls_in_sni is a valid domain, by an arbitrary email address [email protected] .
  46. # Then, we extract the domain with a function that would fail if the email address is invalid.
  47. # If the certificate exists, we will use it, otherwise the default certificate in /etc/ssl will be used.
  48. tls_certificate = \
  49. ${if and {\
  50. { eq {${domain:foo@$tls_in_sni}} {$tls_in_sni}}\
  51. { exists{/usr/local/hestia/ssl/mail/$tls_in_sni.crt} }\
  52. }\
  53. {/usr/local/hestia/ssl/mail/$tls_in_sni.crt}\
  54. {/usr/local/hestia/ssl/certificate.crt}\
  55. }
  56.  
  57. tls_privatekey = \
  58. ${if and {\
  59. { eq {${domain:foo@$tls_in_sni}} {$tls_in_sni}}\
  60. { exists{/usr/local/hestia/ssl/mail/$tls_in_sni.key} }\
  61. }\
  62. {/usr/local/hestia/ssl/mail/$tls_in_sni.key}\
  63. {/usr/local/hestia/ssl/certificate.key}\
  64. }
  65.  
  66. daemon_smtp_ports = 25 : 465 : 587
  67. tls_on_connect_ports = 465
  68. never_users = root
  69. host_lookup = *
  70. rfc1413_hosts = *
  71. rfc1413_query_timeout = 0s
  72. ignore_bounce_errors_after = 2d
  73. timeout_frozen_after = 7d
  74.  
  75. DKIM_DOMAIN = ${lc:${domain:$h_from:}}
  76. DKIM_FILE = /etc/exim4/domains/${lc:${domain:$h_from:}}/dkim.pem
  77. DKIM_PRIVATE_KEY = ${if exists{DKIM_FILE}{DKIM_FILE}{0}}
  78.  
  79. OUTGOING_IP = /etc/exim4/domains/$sender_address_domain/ip
  80.  
  81. SMTP_RELAY_FILE = ${if exists{/etc/exim4/domains/${sender_address_domain}/smtp_relay.conf}{/etc/exim4/domains/$sender_address_domain/smtp_relay.conf}{/etc/exim4/smtp_relay.conf}}
  82. SMTP_RELAY_HOST = ${lookup{host}lsearch{SMTP_RELAY_FILE}}
  83. SMTP_RELAY_PORT = ${lookup{port}lsearch{SMTP_RELAY_FILE}}
  84. SMTP_RELAY_USER = ${lookup{user}lsearch{SMTP_RELAY_FILE}}
  85. SMTP_RELAY_PASS = ${lookup{pass}lsearch{SMTP_RELAY_FILE}}
  86.  
  87. ######################################################################
  88. # ACL CONFIGURATION #
  89. # Specifies access control lists for incoming SMTP mail #
  90. ######################################################################
  91.  
  92. acl_not_smtp = acl_not_smtp
  93.  
  94. begin acl
  95.  
  96. # Limit per user for PHP scripts
  97. acl_not_smtp:
  98. deny message = Website of user $authenticated_id is sending too many emails - rate overlimit = $sender_rate / $sender_rate_period
  99. ratelimit = 200 / 1h / $authenticated_id
  100.  
  101. warn ratelimit = 100 / 1h / strict / $authenticated_id
  102. log_message = Sender rate [limitlog]: log / account / $authenticated_id / $sender_rate / $sender_rate_period
  103.  
  104. accept
  105.  
  106. acl_check_spammers:
  107. accept hosts = +whitelist
  108.  
  109. drop message = Your host in blacklist on this server.
  110. log_message = Host in blacklist
  111. hosts = +spammers
  112.  
  113. accept
  114.  
  115.  
  116. acl_check_mail:
  117. deny condition = ${if eq{$sender_helo_name}{}}
  118. message = HELO required before MAIL
  119.  
  120. drop message = Helo name contains an IP address (HELO was $sender_helo_name) and not is valid
  121. 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}}
  122. condition = ${if match {${lookup dnsdb{>: defer_never,ptr=$sender_host_address}}\}{$sender_helo_name}{no}{yes}}
  123. delay = 45s
  124.  
  125. drop condition = ${if isip{$sender_helo_name}}
  126. message = Access denied - Invalid HELO name (See RFC2821 4.1.3)
  127.  
  128. drop condition = ${if eq{[$interface_address]}{$sender_helo_name}}
  129. message = $interface_address is _my_ address
  130.  
  131. accept
  132.  
  133.  
  134. acl_check_rcpt:
  135. accept hosts = :
  136.  
  137. # Limit per email account for SMTP auhenticated users
  138. deny message = Email account $authenticated_id is sending too many emails - rate overlimit = $sender_rate / $sender_rate_period
  139. ratelimit = 200 / 1h / $authenticated_id
  140.  
  141. warn ratelimit = 100 / 1h / strict / $authenticated_id
  142. log_message = Sender rate [limitlog]: log / email / $authenticated_id / $sender_rate / $sender_rate_period
  143.  
  144. deny message = Restricted characters in address
  145. domains = +local_domains
  146. local_parts = ^[.] : ^.*[@%!/|]
  147.  
  148. deny message = Restricted characters in address
  149. domains = !+local_domains
  150. local_parts = ^[./|] : ^.*[@%!] : ^.*/\\.\\./
  151.  
  152. require verify = sender
  153.  
  154. accept hosts = +relay_from_hosts
  155. control = submission
  156.  
  157. accept authenticated = *
  158. control = submission/domain=
  159.  
  160. deny message = Rejected because $sender_host_address is in a black list at $dnslist_domain\n$dnslist_text
  161. hosts = !+whitelist
  162. dnslists = ${readfile {/etc/exim4/dnsbl.conf}{:}}
  163.  
  164. require message = relay not permitted
  165. domains = +local_domains : +relay_to_domains
  166.  
  167. deny message = smtp auth required
  168. sender_domains = +local_domains
  169. !authenticated = *
  170.  
  171. require verify = recipient
  172.  
  173. .ifdef CLAMD
  174. warn set acl_m0 = no
  175.  
  176. warn condition = ${if exists {/etc/exim4/domains/$domain/antivirus}{yes}{no}}
  177. set acl_m0 = yes
  178. .endif
  179.  
  180. .ifdef SPAMASSASSIN
  181. warn set acl_m1 = no
  182.  
  183. warn condition = ${if exists {/etc/exim4/domains/$domain/antispam}{yes}{no}}
  184. set acl_m1 = yes
  185. .endif
  186.  
  187. accept
  188.  
  189.  
  190. acl_check_data:
  191. .ifdef CLAMD
  192. deny message = Message contains a virus ($malware_name) and has been rejected
  193. malware = */defer_ok
  194. condition = ${if eq{$acl_m0}{yes}{yes}{no}}
  195. .endif
  196.  
  197. .ifdef SPAMASSASSIN
  198. warn !authenticated = *
  199. hosts = !+relay_from_hosts
  200. condition = ${if < {$message_size}{1024K}}
  201. condition = ${if eq{$acl_m1}{yes}{yes}{no}}
  202. spam = debian-spamd:true/defer_ok
  203. add_header = X-Spam-Score: $spam_score_int
  204. add_header = X-Spam-Bar: $spam_bar
  205. add_header = X-Spam-Report: $spam_report
  206. set acl_m2 = $spam_score_int
  207.  
  208. warn condition = ${if !eq{$acl_m2}{} {yes}{no}}
  209. condition = ${if >{$acl_m2}{SPAM_SCORE} {yes}{no}}
  210. add_header = X-Spam-Status: Yes
  211. message = SpamAssassin detected spam (from $sender_address to $recipients).
  212. .endif
  213.  
  214. accept
  215.  
  216.  
  217. acl_check_mime:
  218. deny message = Blacklisted file extension detected
  219. condition = ${if match {${lc:$mime_filename}}{\N(\.ace|\.ade|\.adp|\.app|\.arj|\.asp|\.aspx|\.asx|\.bas|\.bat|\.cab|\.cer|\.chm|\.cmd|\.cnt|\.com|\.cpl|\.crt|\.csh|\.der|\.diagcab|\.dll|\.efi|\.exe|\.fla|\.fon|\.fxp|\.gadget|\.grp|\.hlp|\.hpj|\.hta|\.htc|\.img|\.inf|\.ins|\.iso|\.isp|\.its|\.jar|\.jnlp|\.js|\.jse|\.ksh|\.lib|\.lnk|\.mad|\.maf|\.mag|\.mam|\.maq|\.mar|\.mas|\.mat|\.mau|\.mav|\.maw|\.mcf|\.mda|\.mdb|\.mde|\.mdt|\.mdw|\.mdz|\.msc|\.msh|\.msh1|\.msh1xml|\.msh2|\.msh2xml|\.mshxml|\.msi|\.msp|\.mst|\.msu|\.ops|\.osd|\.pcd|\.pif|\.pl|\.plg|\.prf|\.prg|\.printerexport|\.ps1|\.ps1xml|\.ps2|\.ps2xml|\.psc1|\.psc2|\.psd1|\.psdm1|\.pst|\.py|\.pyc|\.pyo|\.pyw|\.pyz|\.pyzw|\.reg|\.scf|\.scr|\.sct|\.sfx|\.shb|\.shs|\.swf|\.sys|\.theme|\.tmp|\.ttf|\.url|\.vb|\.vba|\.vbe|\.vbp|\.vbs|\.vhd|\.vhdx|\.vsmacros|\.vsw|\.vxd|\.webpnp|\.website|\.wim|\.ws|\.wsc|\.wsf|\.wsh|\.xbap|\.xll|\.xnk)$\N}{1}{0}}
  220.  
  221. accept
  222.  
  223.  
  224.  
  225. ######################################################################
  226. # AUTHENTICATION CONFIGURATION #
  227. ######################################################################
  228. begin authenticators
  229.  
  230. smtp_relay_login:
  231. driver = plaintext
  232. public_name = LOGIN
  233. hide client_send = : SMTP_RELAY_USER : SMTP_RELAY_PASS
  234.  
  235. dovecot_plain:
  236. driver = dovecot
  237. public_name = PLAIN
  238. server_socket = /var/run/dovecot/auth-client
  239. server_set_id = $auth1
  240.  
  241. dovecot_login:
  242. driver = dovecot
  243. public_name = LOGIN
  244. server_socket = /var/run/dovecot/auth-client
  245. server_set_id = $auth1
  246.  
  247.  
  248.  
  249. ######################################################################
  250. # ROUTERS CONFIGURATION #
  251. # Specifies how addresses are handled #
  252. ######################################################################
  253. begin routers
  254.  
  255. send_via_smtp_relay:
  256. driver = manualroute
  257. address_data = SMTP_RELAY_HOST:SMTP_RELAY_PORT
  258. domains = !+local_domains
  259. require_files = SMTP_RELAY_FILE
  260. transport = smtp_relay_smtp
  261. route_list = * ${extract{1}{:}{$address_data}}::${extract{2}{:}{$address_data}}
  262. no_more
  263. no_verify
  264.  
  265. dnslookup:
  266. driver = dnslookup
  267. domains = !+local_domains
  268. transport = remote_smtp
  269. no_more
  270.  
  271. userforward:
  272. driver = redirect
  273. check_local_user
  274. file = $home/.forward
  275. require_files = ${local_part}:+${home}/.forward
  276. domains = +local_domains
  277. allow_filter
  278. no_verify
  279. no_expn
  280. check_ancestor
  281. file_transport = address_file
  282. pipe_transport = address_pipe
  283. reply_transport = address_reply
  284.  
  285. procmail:
  286. driver = accept
  287. check_local_user
  288. require_files = ${local_part}:+${home}/.procmailrc:/usr/bin/procmail
  289. transport = procmail
  290. no_verify
  291.  
  292. autoreplay:
  293. driver = accept
  294. require_files = /etc/exim4/domains/$domain/autoreply.${local_part}.msg
  295. condition = ${if exists{/etc/exim4/domains/$domain/autoreply.${local_part}.msg}{yes}{no}}
  296. retry_use_local_part
  297. transport = userautoreply
  298. unseen
  299.  
  300. aliases:
  301. driver = redirect
  302. headers_add = X-redirected: yes
  303. data = ${extract{1}{:}{${lookup{$local_part@$domain}lsearch{/etc/exim4/domains/$domain/aliases}}}}
  304. require_files = /etc/exim4/domains/$domain/aliases
  305. redirect_router = dnslookup
  306. pipe_transport = address_pipe
  307. unseen
  308.  
  309. localuser_fwd_only:
  310. driver = accept
  311. transport = devnull
  312. condition = ${if exists{/etc/exim4/domains/$domain/fwd_only}{${lookup{$local_part}lsearch{/etc/exim4/domains/$domain/fwd_only}{true}{false}}}}
  313.  
  314. localuser_spam:
  315. driver = accept
  316. transport = local_spam_delivery
  317. 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}}}}
  318.  
  319. localuser:
  320. driver = accept
  321. transport = local_delivery
  322. condition = ${lookup{$local_part}lsearch{/etc/exim4/domains/$domain/passwd}{true}{false}}
  323.  
  324. catchall:
  325. driver = redirect
  326. headers_add = X-redirected: yes
  327. require_files = /etc/exim4/domains/$domain/aliases
  328. data = ${extract{1}{:}{${lookup{*@$domain}lsearch{/etc/exim4/domains/$domain/aliases}}}}
  329. file_transport = local_delivery
  330. redirect_router = dnslookup
  331.  
  332. terminate_alias:
  333. driver = accept
  334. transport = devnull
  335. condition = ${lookup{$local_part@$domain}lsearch{/etc/exim4/domains/$domain/aliases}{true}{false}}
  336.  
  337.  
  338.  
  339. ######################################################################
  340. # TRANSPORTS CONFIGURATION #
  341. ######################################################################
  342. begin transports
  343.  
  344. smtp_relay_smtp:
  345. driver = smtp
  346. hosts_require_auth = $host_address
  347. hosts_require_tls = $host_address
  348.  
  349. remote_smtp:
  350. driver = smtp
  351. helo_data = ${if exists {/etc/exim4/mailhelo.conf}{${lookup{$sending_ip_address}lsearch{/etc/exim4/mailhelo.conf}{$value}{$primary_hostname}}}{$primary_hostname}}
  352. dkim_domain = DKIM_DOMAIN
  353. dkim_selector = mail
  354. dkim_private_key = DKIM_PRIVATE_KEY
  355. dkim_canon = relaxed
  356. dkim_strict = 0
  357. interface = ${if exists{OUTGOING_IP}{${readfile{OUTGOING_IP}}}}
  358.  
  359. procmail:
  360. driver = pipe
  361. command = "/usr/bin/procmail -d $local_part"
  362. return_path_add
  363. delivery_date_add
  364. envelope_to_add
  365. user = $local_part
  366. initgroups
  367. return_output
  368.  
  369. local_delivery:
  370. driver = appendfile
  371. maildir_format
  372. maildir_use_size_file
  373. user = ${extract{2}{:}{${lookup{$local_part}lsearch{/etc/exim4/domains/$domain/passwd}}}}
  374. group = mail
  375. create_directory
  376. directory_mode = 770
  377. mode = 660
  378. use_lockfile = no
  379. delivery_date_add
  380. envelope_to_add
  381. return_path_add
  382. directory = "${extract{5}{:}{${lookup{$local_part}lsearch{/etc/exim4/domains/$domain/passwd}}}}/mail/$domain/$local_part"
  383. quota = ${extract{6}{:}{${lookup{$local_part}lsearch{/etc/exim4/domains/$domain/passwd}}}}M
  384. quota_warn_threshold = 75%
  385.  
  386. local_spam_delivery:
  387. driver = appendfile
  388. maildir_format
  389. maildir_use_size_file
  390. user = ${extract{2}{:}{${lookup{$local_part}lsearch{/etc/exim4/domains/$domain/passwd}}}}
  391. group = mail
  392. create_directory
  393. directory_mode = 770
  394. mode = 660
  395. use_lockfile = no
  396. delivery_date_add
  397. envelope_to_add
  398. return_path_add
  399. directory = "${extract{5}{:}{${lookup{$local_part}lsearch{/etc/exim4/domains/$domain/passwd}}}}/mail/$domain/$local_part/.Spam"
  400. quota = ${extract{6}{:}{${lookup{$local_part}lsearch{/etc/exim4/domains/$domain/passwd}}}}M
  401. quota_directory = "${extract{5}{:}{${lookup{$local_part}lsearch{/etc/exim4/domains/$domain/passwd}}}}/mail/$domain/$local_part"
  402. quota_warn_threshold = 75%
  403.  
  404. address_pipe:
  405. driver = pipe
  406. return_output
  407.  
  408. address_file:
  409. driver = appendfile
  410. delivery_date_add
  411. envelope_to_add
  412. return_path_add
  413.  
  414. address_reply:
  415. driver = autoreply
  416.  
  417. userautoreply:
  418. driver = autoreply
  419. file = /etc/exim4/domains/$domain/autoreply.${local_part}.msg
  420. from = "${local_part}@${domain}"
  421. headers = Content-Type: text/plain; charset=utf-8;\nContent-Transfer-Encoding: 8bit
  422. subject = "${if def:h_Subject: {Autoreply: \"${rfc2047:$h_Subject:}\"} {Autoreply Message}}"
  423. to = "${sender_address}"
  424.  
  425. devnull:
  426. driver = appendfile
  427. file = /dev/null
  428.  
  429.  
  430.  
  431. ######################################################################
  432. # RETRY CONFIGURATION #
  433. ######################################################################
  434. begin retry
  435.  
  436. # Address or Domain Error Retries
  437. # ----------------- ----- -------
  438. * * F,2h,15m; G,16h,1h,1.5; F,4d,6h
  439.  
  440.  
  441.  
  442. ######################################################################
  443. # REWRITE CONFIGURATION #
  444. ######################################################################
  445. begin rewrite
  446.  
  447.  
  448.  
  449. ######################################################################
  450.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement