Re: Re: Pipe to PHP script using Sieve Extprograms

2017-04-21 Thread Thomas

Oops, the configuration files in conf.d weren't included. They are now.

I am now seeing the follow errors showing up in the maillogs:

   dovecot: master: Error: bind(/var/run/dovecot/sieve-pipe/php)
   failed: No such file or directory
   dovecot: master: Fatal: Failed to start listeners

I may be completely wrong here, but isn't it supposed to create this on 
its own since it's a unix listener?


The service looks like this now:

   service php {
  # Define the executed script as parameter to the sieve service
  executable = script /etc/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
  }
   }


Re: Pipe to PHP script using Sieve Extprograms

2017-04-21 Thread Stephan Bosch
Op 4/21/2017 om 6:08 PM schreef Thomas:
> 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 don't see these settings in your dovecot -n output below.

>
> 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 supp...@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 = ssl_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
>}


Pipe to PHP script using Sieve Extprograms

2017-04-21 Thread Thomas

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 supp...@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 =