Hello,
I seem to be having some issues trying to setup a pipe to PHP scripts using Sieve Extprograms. I am trying to allow each individual mailbox to setup its own PHP pipe rules (in other words, each user should be able to pipe incoming emails to a user defined PHP script).
I have the following lines in my main Sieve configuration file (/etc/dovecot/conf.d/90-sieve.conf):
sieve_extensions = +vnd.dovecot.pipe
sieve_global_extensions = +vnd.dovecot.pipe +vnd.dovecot.execute
sieve_plugins = sieve_extprograms
I have configured a Sieve service that looks like this (/etc/dovecot/conf.d/90-sieve-extprograms.conf):
service php {
# Define the executed script as parameter to the sieve service
executable = /var/run/dovecot/sieve-pipe/php.sh
# Use some unprivileged user for executing the program
user = dovenull
# The unix socket located in the sieve_pipe_socket_dir (as
defined in the
# plugin {} section above)
unix_listener sieve-pipe/php {
# LDA/LMTP must have access
user = vmail
mode = 0600
}
}
Contents of /var/run/dovecot/sieve-pipe/php.sh:
#!/usr/bin/php
Sieve script for one of my mailboxes:
require ["fileinto", "regex", "date", "relational", "vacation"];
require ["mailbox", "imap4flags", "vnd.dovecot.pipe"];
# Move spam to spam folder
if header :contains "X-Spam-Flag" "YES" {
fileinto "Junk";
# Stop here so that we do not reply on spams
stop;
}
pipe :try "php /var/www/web2/piping.php support@example.com"
keep;
This results however in the following error in my log file:
main script: line 5: error: require command: unknown Sieve
capability `vnd.dovecot.pipe'.
main script: line 14: error: unknown command 'pipe' (only reported
once at first occurence).
main script: error: validation failed.
I am also not quite confident I have set this up correctly. Am I heading in the right direction for what I am trying to achieve?
Dovecot version: 2.2.10
dovecot -n:
# 2.2.10: /etc/dovecot/dovecot.conf
# OS: Linux 3.10.0-514.16.1.el7.x86_64 x86_64 CentOS Linux release
7.3.1611 (Core)
auth_mechanisms = plain login
disable_plaintext_auth = no
listen = *,[::]
log_timestamp = "%Y-%m-%d %H:%M:%S "
mail_plugins = " quota"
mail_privileged_group = vmail
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 ihave
passdb {
args = /etc/dovecot-sql.conf
driver = sql
}
plugin {
quota = dict:user::file:/var/vmail/%d/%n/.quotausage
sieve = /var/vmail/%d/%n/.sieve
}
protocols = imap pop3
service auth {
unix_listener /var/spool/postfix/private/auth {
group = postfix
mode = 0660
user = postfix
}
unix_listener auth-userdb {
group = vmail
mode = 0600
user = vmail
}
user = root
}
service imap-login {
client_limit = 1000
process_limit = 500
}
service lmtp {
unix_listener /var/spool/postfix/private/dovecot-lmtp {
group = postfix
mode = 0600
user = postfix
}
}
ssl_cert = </etc/postfix/smtpd.cert
ssl_key = </etc/postfix/smtpd.key
ssl_protocols = !SSLv2 !SSLv3
userdb {
driver = prefetch
}
userdb {
args = /etc/dovecot-sql.conf
driver = sql
}
protocol imap {
mail_plugins = quota imap_quota
}
protocol pop3 {
mail_plugins = quota
pop3_uidl_format = %08Xu%08Xv
}
protocol lda {
mail_plugins = sieve quota
postmaster_address = root@localhost
}
protocol lmtp {
mail_plugins = quota sieve
postmaster_address = webmaster@localhost
}