I have to reject office files for a certain domain plus notifying the
original recipient about the rejection too.
require
["fileinto","reject","body","enotify","variables"];
if allof (address :contains
["To","TO","Cc","CC"]
"@example.org", body
:content? "application/msword" :contains "") {
??????? set "to" "${1}";
??????? # :matches is used to get the value of the Subject header
??????? if header :matches "Subject" "*" {
??????????????? set "subject" "${1}";
??????? }
??????? # :matches is used to get the value of the From header
??????? if header :matches "From" "*" {
??????????????? set "from" "${1}";
??????? }
??????? notify :message "Rejected Office Datei ${from}: ${subject}"
"${to}";
??????? reject text:
Aus Sicherheitsgr?nden nehmen wir keine Office Dateien mehr an. Bitte
senden Sie uns ein PDF.
.
;
}
A manual sievec call gives not error and if I remove everything but the
reject line it works.
Any ideas?
--
Ralf Becker
EGroupware GmbH [www.egroupware.org]
Handelsregister HRB Kaiserslautern 3587
Gesch?ftsf?hrer Birgit und Ralf Becker
Leibnizstr. 17, 67663 Kaiserslautern, Germany
Telefon +49 631 31657-0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: OpenPGP digital signature
URL:
<https://dovecot.org/pipermail/dovecot/attachments/20190114/b945b47c/attachment.sig>
Ralf Becker
2019-Jan-15 17:51 UTC
Solved: Sieve: reject certain mime-types and notify recipient
I case someone is interesed too, why it was not working: Am 14.01.19 um 20:22 schrieb Ralf Becker:> I have to reject office files for a certain domain plus notifying the > original recipient about the rejection too. > > require ["fileinto","reject","body","enotify","variables"]; > > if allof (address :contains ["To","TO","Cc","CC"] "@example.org", body > :content? "application/msword" :contains "") { > ??????? set "to" "${1}";The set does not work in allof with an other condition, so I use now: if address :contains ["To","TO","Cc","CC"] "@example.org" { ??? set "to" "${1}"; }> ??????? # :matches is used to get the value of the Subject header > ??????? if header :matches "Subject" "*" { > ??????????????? set "subject" "${1}"; > ??????? } > ??????? # :matches is used to get the value of the From header > ??????? if header :matches "From" "*" { > ??????????????? set "from" "${1}"; > ??????? } > ??????? notify :message "Rejected Office Datei ${from}: ${subject}" "${to}";The notify needs as argument "mailto:${to}".> ??????? reject text: > Aus Sicherheitsgr?nden nehmen wir keine Office Dateien mehr an. Bitte > senden Sie uns ein PDF. > . > ; > } > > A manual sievec call gives not error and if I remove everything but the > reject line it works. > > Any ideas?I used the sieve-test binary to figure out why it was not working. My full script for checking mime-types as well as extensions and also notifying the orginal recipient is now the following: require [ "foreverypart", "mime", "fileinto","reject","body","enotify","variables"]; if address :contains ["To","TO","Cc","CC"] "@example.org" { ??????? # :matches is used to get value of to, subject and from ??????? if address :matches ["To","TO","Cc","CC"] "*" { ??????????????? set "to" "${1}"; ??????? } ??????? if header :matches "Subject" "*" { ??????????????? set "subject" "${1}"; ??????? } ??????? if header :matches "From" "*" { ??????????????? set "from" "${1}"; ??????? } ??????? # reject based on mime-type ??????? if allof(body :content? "application/msword" :contains "", ???????????????? body :content? "application/msexcel" :contains "") { ??????????????? # send notification to original recipient ??????????????? notify :message "Rejected Office Datei von ${from}: ${subject}" "mailto:${to}"; ??????????????? # send rejection message to sender ??????????????? reject text: Aus Sicherheitsgr?nden nehmen wir keine Office Dateien mehr an. Bitte senden Sie uns ein PDF. -- Ralf Becker EGroupware GmbH . ; ??????????????? stop; ??????? } ??????? # reject based on extension of attachment ??????? foreverypart ??????? { ??????????????? if header :mime :param "filename" :matches ["Content-Type", "Content-Disposition"] ??????????????????????? ["*.doc","*.xsl"] ??????????????? { ??????????????????????? # send notification to original recipient ??????????????????????? notify :message "Rejected Dateierweiterung/Fileextension ${from}: ${subject}" "mailto:${to}"; ??????????????????????? # send rejection message to sender ??????????????????????? reject text: Aus Sicherheitsgr?nden nehmen wir kein Office Dateien mehr an. Bitte senden Sie uns ein PDF. -- Ralf Becker EGroupware GmbH . ; ??????????????????????? stop; ??????????????? } ??????? } } Ralf -- Ralf Becker EGroupware GmbH [www.egroupware.org] Handelsregister HRB Kaiserslautern 3587 Gesch?ftsf?hrer Birgit und Ralf Becker Leibnizstr. 17, 67663 Kaiserslautern, Germany Telefon +49 631 31657-0 -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 801 bytes Desc: OpenPGP digital signature URL: <https://dovecot.org/pipermail/dovecot/attachments/20190115/bf4ed708/attachment.sig>
i recently upgraded a server from dovecot 2.1 to 2.3
unfortunately sieve does not appear to be working. The user scripts have
not changed, and neither has the dovecont config. using managesieve
allows me to create new sieve files and setting one as default updates
the link in ~/ to point to the correct file, but the .dovecot.svbin file
is not changed (unless i run sievec /home/username/.dovecot.sieve )
I have tested an out of office script that was working on the old
system, and a simple test script that flags the mail as $label1 as per
an example.
email arrives in users mailboxes but sieve scripts don't appear to be
doing anything. below is the output of doveconf -n (hostname changed for
security)
# 2.3.1 (8e2f634): /etc/dovecot/dovecot.conf
# Pigeonhole version 0.5.1 (d9bc6dfe)
# OS: Linux 4.19.14 x86_64 Slackware 14.2 ext4
# Hostname: mail.myserver.net
base_dir = /var/run/dovecot/
debug_log_path = /var/log/dovecot.log
default_client_limit = 6000
default_process_limit = 1300
hostname = mail.myserver.net
info_log_path = /var/log/dovecot.info
lda_mailbox_autocreate = yes
lda_mailbox_autosubscribe = yes
listen = 10.1.1.100
login_greeting = Dovecot at mcfadyens.net
login_log_format_elements = user=<%u> method=%m rip=%r lip=%l mpid=%e %c
mail_location = maildir:/var/spool/dovecot/%n
mail_log_prefix = "%s(%u): "
managesieve_notify_capability = mailto
managesieve_sieve_capability = fileinto reject envelope
encoded-character vacation subaddress comparator-i;ascii-numeric
relational regex imap4flags copy include variables body enotify
environment mailbox date index ihave duplicate mime foreverypart extracttext
passdb {
? driver = shadow
}
plugin {
? mail_log_events = delete undelete expunge copy mailbox_delete
mailbox_rename
? mail_log_fields = uid box msgid size
? mail_log_group_events = yes
? sieve = file:~/sieve;active=~/.dovecot.sieve
? sieve_dir = ~/sieve
? sieve_user_log = ~/.dovecot.sieve.log
}
protocols = imap lmtp sieve
service managesieve-login {
? inet_listener sieve {
??? port = 4190
? }
? service_count = 0
? vsz_limit = 128 M
}
ssl = required
ssl_cert = </etc/ssl/certs/dovecot.cert
ssl_dh =? # hidden, use -P to show it
ssl_key =? # hidden, use -P to show it
userdb {
? driver = passwd
}
protocol lda {
? mail_plugins = " sieve"
}
protocol lmtp {
? mail_plugins = " sieve"
}
protocol imap {
? mail_max_userip_connections = 30
}
Any pointers on what might be wrong or how to test would be appreciated,
thanks, Tim
(the os is 64bit slackware 14.2, in case it is relevant)
Reasonably Related Threads
- Solved: Sieve: reject certain mime-types and notify recipient
- doveadm mailbox delete not working
- Sieve and OX push_notification_drive seem to not work together
- How to access mailbox metadata in Lua push driver
- sieve stopped working and doveadm mailbox list without -s shows less folders then with