exim4:sieve_filter
This is an old revision of the document!
Table of Contents
Exim4 - Sieve Filter
Exim4 Sieve filter.
The filter contains an automatic response and a forwarding.
router
userforward: driver = redirect allow_filter user = mail group = mail file = /var/vmail/${domain}/${local_part}/${if exists{/var/vmail/${domain}/${local_part}/active_script}{active_script{}}}{forward}} no_verify no_expn check_ancestor file_transport = local_delivery pipe_transport = address_pipe reply_transport = address_reply condition = ${if exists{/var/vmail/${domain}/${local_part}/forward}{yes}{${if exists{/var/vmail/${domain}/${local_part}/active_script}{yes}{no}}}}
Transport
local_delivery: driver = appendfile check_string = "" delivery_date_add directory = /var/vmail/${domain}/${local_part}/${sg{${sg{/${address_file}}{/+}{.}}}{(?i)^.inbox}{}} directory_mode = 770 envelope_to_add group = mail maildir_format maildir_tag = ,S=$message_size message_prefix = "" message_suffix = "" mode = 0660
active_script
# Sieve filter require ["fileinto", "copy", "vacation"] ; #begin = forward = #data=1~dGlub0BuYXVtaXguZGU= redirect :copy "copy@domain.tld"; #end = forward = #begin = autoresponder = #data=1~YXV0b3Jlc3BvbmQAZGFzIGlzdCBlaW5lIGF1dG9tYXRpc2NoZSBtYWls vacation :days 1 :subject "Automatic Mail" "This is automatic Mail"; #end = autoresponder =
Another approach
Should you want to use Exim's Sieve support there are three main caveats:
- Sieve files accessed from redirect routers need to be readable by the uid of the process that handles the SMTP connection, (e.g. Debian-exim)
- While the Sieve RFC specifies that files use CRLF as linebreaks, Exim filters usually require the use of LF only.
- Exim requires that sieve filter files identify themselves with “# Sieve filter” which is not part of the Sieve spec.
ACTIVE_SIEVE = /var/lib/sieve/${domain}/${local_part}/active VACATION_DIR = /var/lib/sieve/${domain}/${local_part}/vacation VDOM_MAILDIR = /var/vmail/${domain}/${local_part}
The following router is installed to /etc/exim4/conf.d/router/350_local_sieve
vdom_sieve: debug_print = "R: vdom_sieve for $local_part@$domain" driver = redirect domains = +local_domains require_files = ACTIVE_SIEVE no_verify no_expn check_ancestor allow_filter = true local_part_suffix = +* : -* local_part_suffix_optional data = "#Sieve filter\n${sg{${readfile{ACTIVE_SIEVE}}}{\r}{}}" sieve_useraddress = "$local_part" sieve_subaddress = "${sg{$local_part_suffix}{^.}{}}" sieve_vacation_directory = VACATION_DIR pipe_transport = address_pipe reply_transport = address_reply file_transport = vdom_sieve_file
Note, the redirect router allows either “+” or “-” as a suffix, which may need to be tweaked depending on site requirements.
/etc/exim4/conf.d/transport/40_local_sieve
vdom_sieve_file: debug_print = "T: vdom_sieve_file for $local_part@$domain ($address_file)" driver = appendfile delivery_date_add envelope_to_add return_path_add directory = VDOM_MAILDIR/${sg {.${sg {$address_file}{/}{.}}/} \ {^.(INBOX|inbox)/} {}} maildir_format = true user = vmail group = vmail
Note: The directory line might need a little fixing to fully support Maildir, but currently it replaces “/” characters with dots and assumes “inbox” as the user maildir root.
References
exim4/sieve_filter.1479134605.txt.gz · Last modified: 2020/07/15 09:30 (external edit)