Commit 6cc49f24 authored by tbrehm's avatar tbrehm
Browse files

Added support for dovecot in Debian Lenny.

Added Support for Sieve mail filtering language on dovecot servers.
parent 1f16ae51
......@@ -124,6 +124,11 @@ $conf['courier']['courier-imap-ssl'] = '';
$conf['courier']['courier-pop'] = '';
$conf['courier']['courier-pop-ssl'] = '';
//* Dovecot
$conf['dovecot']['installed'] = false; // will be detected automatically during installation
$conf['dovecot']['config_dir'] = '/etc/dovecot';
$conf['dovecot']['init_script'] = 'dovecot';
//* SASL
$conf['saslauthd']['installed'] = false; // will be detected automatically during installation
$conf['saslauthd']['config'] = '/etc/sysconfig/saslauthd';
......
......@@ -124,6 +124,11 @@ $conf['courier']['courier-imap-ssl'] = '';
$conf['courier']['courier-pop'] = '';
$conf['courier']['courier-pop-ssl'] = '';
//* Dovecot
$conf['dovecot']['installed'] = false; // will be detected automatically during installation
$conf['dovecot']['config_dir'] = '/etc/dovecot';
$conf['dovecot']['init_script'] = 'dovecot';
//* SASL
$conf['saslauthd']['installed'] = false; // will be detected automatically during installation
$conf['saslauthd']['config'] = '/etc/sysconfig/saslauthd';
......
......@@ -123,6 +123,11 @@ $conf['courier']['courier-imap'] = 'courier-imap';
$conf['courier']['courier-imap-ssl'] = 'courier-imap-ssl';
$conf['courier']['courier-pop'] = 'courier-pop';
$conf['courier']['courier-pop-ssl'] = 'courier-pop-ssl';
$conf['dovecot']['init_script'] = 'dovecot';
//* Dovecot
$conf['dovecot']['installed'] = false; // will be detected automatically during installation
$conf['dovecot']['config_dir'] = '/etc/dovecot';
//* SASL
$conf['saslauthd']['installed'] = false; // will be detected automatically during installation
......
......@@ -124,6 +124,11 @@ $conf['courier']['courier-imap-ssl'] = 'courier-imap';
$conf['courier']['courier-pop'] = 'courier-imap';
$conf['courier']['courier-pop-ssl'] = 'courier-imap';
//* Dovecot
$conf['dovecot']['installed'] = false; // will be detected automatically during installation
$conf['dovecot']['config_dir'] = '/etc/dovecot';
$conf['dovecot']['init_script'] = 'dovecot';
//* SASL
$conf['saslauthd']['installed'] = false; // will be detected automatically during installation
$conf['saslauthd']['config'] = '/etc/sysconfig/saslauthd';
......
......@@ -148,6 +148,11 @@ $conf['courier']['courier-imap-ssl'] = 'courier-imapd-ssl';
$conf['courier']['courier-pop'] = 'courier-pop3d';
$conf['courier']['courier-pop-ssl'] = 'courier-pop3d-ssl';
//* Dovecot
$conf['dovecot']['installed'] = false; // will be detected automatically during installation
$conf['dovecot']['config_dir'] = '/etc/dovecot';
$conf['dovecot']['init_script'] = 'dovecot';
//* SASL
$conf['saslauthd']['installed'] = false; // will be detected automatically during installation
$conf['saslauthd']['config_file'] = '/etc/conf.d/saslauthd';
......
......@@ -124,6 +124,11 @@ $conf['courier']['courier-imap-ssl'] = 'courier-imap-ssl';
$conf['courier']['courier-pop'] = 'courier-pop';
$conf['courier']['courier-pop-ssl'] = 'courier-pop-ssl';
//* Dovecot
$conf['dovecot']['installed'] = false; // will be detected automatically during installation
$conf['dovecot']['config_dir'] = '/etc/dovecot';
$conf['dovecot']['init_script'] = 'dovecot';
//* SASL
$conf['saslauthd']['installed'] = false; // will be detected automatically during installation
$conf['saslauthd']['config'] = '/etc/default/saslauthd';
......
......@@ -171,9 +171,15 @@ if($install_mode == 'standard') {
swriteln('Configuring PAM');
$inst->configure_pam();
if($conf['dovecot']['installed'] == true) {
//* Configure dovecot
swriteln('Configuring Dovecot');
$inst->configure_dovecot();
} else {
//* Configure courier
swriteln('Configuring Courier');
$inst->configure_courier();
}
//* Configure Spamasassin
swriteln('Configuring Spamassassin');
......@@ -247,6 +253,7 @@ if($install_mode == 'standard') {
if($conf['courier']['courier-imap-ssl'] != '' && is_file($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'].' restart');
if($conf['courier']['courier-pop'] != '' && is_file($conf['init_scripts'].'/'.$conf['courier']['courier-pop'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-pop'].' restart');
if($conf['courier']['courier-pop-ssl'] != '' && is_file($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'].' restart');
if($conf['dovecot']['init_script'] != '' && is_file($conf['init_scripts'].'/'.$conf['dovecot']['init_script'])) system($conf['init_scripts'].'/'.$conf['dovecot']['init_script'].' restart');
if($conf['apache']['init_script'] != '' && is_file($conf['init_scripts'].'/'.$conf['apache']['init_script'])) system($conf['init_scripts'].'/'.$conf['apache']['init_script'].' restart');
if($conf['pureftpd']['init_script'] != '' && is_file($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'])) system($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'].' restart');
if($conf['mydns']['installed'] == true && $conf['mydns']['init_script'] != '' && is_file($conf['init_scripts'].'/'.$conf['mydns']['init_script'])) system($conf['init_scripts'].'/'.$conf['mydns']['init_script'].' restart &> /dev/null');
......@@ -328,9 +335,15 @@ if($install_mode == 'standard') {
swriteln('Configuring PAM');
$inst->configure_pam();
if($conf['dovecot']['installed'] == true) {
//* Configure dovecot
swriteln('Configuring Dovecot');
$inst->configure_dovecot();
} else {
//* Configure courier
swriteln('Configuring Courier');
$inst->configure_courier();
}
//* Configure Spamasassin
swriteln('Configuring Spamassassin');
......@@ -353,6 +366,7 @@ if($install_mode == 'standard') {
if($conf['courier']['courier-imap-ssl'] != '') system($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'].' restart');
if($conf['courier']['courier-pop'] != '') system($conf['init_scripts'].'/'.$conf['courier']['courier-pop'].' restart');
if($conf['courier']['courier-pop-ssl'] != '') system($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'].' restart');
if($conf['dovecot']['init_script'] != '' && is_file($conf['init_scripts'].'/'.$conf['dovecot']['init_script'])) system($conf['init_scripts'].'/'.$conf['dovecot']['init_script'].' restart');
}
//** Configure Jailkit
......
......@@ -121,6 +121,7 @@ class installer_base {
if(is_installed('apache') || is_installed('apache2') || is_installed('httpd')) $conf['apache']['installed'] = true;
if(is_installed('getmail')) $conf['getmail']['installed'] = true;
if(is_installed('couriertcpd')) $conf['courier']['installed'] = true;
if(is_installed('dovecot')) $conf['dovecot']['installed'] = true;
if(is_installed('saslsauthd')) $conf['saslauthd']['installed'] = true;
if(is_installed('amavisd-new')) $conf['amavis']['installed'] = true;
if(is_installed('clamdscan')) $conf['clamav']['installed'] = true;
......@@ -215,6 +216,8 @@ class installer_base {
$tpl_ini_array['web']['security_level'] = 20;
$tpl_ini_array['web']['user'] = $conf['apache']['user'];
$tpl_ini_array['web']['group'] = $conf['apache']['group'];
$tpl_ini_array['mail']['pop3_imap_daemon'] = ($conf['dovecot']['installed'] == true)?'dovecot':'courier';
$tpl_ini_array['mail']['mail_filter_syntax'] = ($conf['dovecot']['installed'] == true)?'sieve':'maildrop';
$server_ini_content = array_to_ini($tpl_ini_array);
$server_ini_content = mysql_real_escape_string($server_ini_content);
......@@ -226,6 +229,8 @@ class installer_base {
$db_server_enabled = ($conf['services']['db'])?1:0;
$vserver_server_enabled = ($conf['services']['vserver'])?1:0;
if($conf['mysql']['master_slave_setup'] == 'y') {
//* Insert the server record in master DB
......@@ -648,6 +653,72 @@ class installer_base {
wf($configfile, $content);
}
public function configure_dovecot()
{
global $conf;
$config_dir = $conf['dovecot']['config_dir'];
//* Configure master.cf and add a line for deliver
if(is_file($config_dir.'/master.cf')){
copy($config_dir.'/master.cf', $config_dir.'/master.cf~2');
}
if(is_file($config_dir.'/master.cf~')){
exec('chmod 400 '.$config_dir.'/master.cf~2');
}
$content = rf($conf["postfix"]["config_dir"].'/master.cf');
// Only add the content if we had not addded it before
if(!stristr($content,"dovecot/deliver")) {
$deliver_content = "dovecot unix - n n - - pipe\n flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}";
af($conf["postfix"]["config_dir"].'/master.cf',$deliver_content);
}
unset($content);
unset($deliver_content);
//* Reconfigure postfix to use dovecot authentication
// Adding the amavisd commands to the postfix configuration
$postconf_commands = array (
'dovecot_destination_recipient_limit = 1',
'virtual_transport = dovecot',
'smtpd_sasl_type = dovecot',
'smtpd_sasl_path = private/auth'
);
// Make a backup copy of the main.cf file
copy($conf["postfix"]["config_dir"].'/main.cf',$conf["postfix"]["config_dir"].'/main.cf~3');
// Executing the postconf commands
foreach($postconf_commands as $cmd) {
$command = "postconf -e '$cmd'";
caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
}
//* copy dovecot.conf
$configfile = 'dovecot.conf';
if(is_file("$config_dir/$configfile")){
copy("$config_dir/$configfile", "$config_dir/$configfile~");
}
copy('tpl/debian_dovecot.conf.master',"$config_dir/$configfile");
//* dovecot-sql.conf
$configfile = 'dovecot-sql.conf';
if(is_file("$config_dir/$configfile")){
copy("$config_dir/$configfile", "$config_dir/$configfile~");
}
exec("chmod 400 $config_dir/$configfile~");
$content = rf("tpl/debian_dovecot-sql.conf.master");
$content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
$content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
$content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
$content = str_replace('{mysql_server_host}',$conf['mysql']['host'],$content);
wf("$config_dir/$configfile", $content);
exec("chmod 600 $config_dir/$configfile");
exec("chown root:root $config_dir/$configfile");
}
public function configure_amavis() {
global $conf;
......
......@@ -549,8 +549,10 @@ CREATE TABLE `mail_user` (
`custom_mailfilter` mediumtext,
`postfix` enum('n','y') NOT NULL,
`access` enum('n','y') NOT NULL,
`disableimap` enum('0','1') NOT NULL default '0',
`disablepop3` enum('0','1') NOT NULL default '0',
`disableimap` enum('n','y') NOT NULL default 'n',
`disablepop3` enum('n','y') NOT NULL default 'n',
`disabledeliver` enum('n','y') NOT NULL default 'n',
`disablesmtp` enum('n','y') NOT NULL default 'n',
PRIMARY KEY (`mailuser_id`),
KEY `server_id` (`server_id`,`email`),
KEY `email_access` (`email`,`access`)
......
# This file is opened as root, so it should be owned by root and mode 0600.
#
# http://wiki.dovecot.org/AuthDatabase/SQL
#
# For the sql passdb module, you'll need a database with a table that
# contains fields for at least the userid and password. If you want to
# use the user@domain syntax, you might want to have a separate domain
# field as well.
#
# If your users all have the same uig/gid, and have predictable home
# directories, you can use the static userdb module to generate the home
# dir based on the userid and domain. In this case, you won't need fields
# for home, uid, or gid in the database.
#
# If you prefer to use the sql userdb module, you'll want to add fields
# for home, uid, and gid. Here is an example table:
#
# CREATE TABLE users (
# userid VARCHAR(128) NOT NULL,
# password VARCHAR(64) NOT NULL,
# home VARCHAR(255) NOT NULL,
# uid INTEGER NOT NULL,
# gid INTEGER NOT NULL,
# active CHAR(1) DEFAULT 'Y' NOT NULL
# );
# Database driver: mysql, pgsql, sqlite
#driver =
# Database connection string. This is driver-specific setting.
#
# pgsql:
# For available options, see the PostgreSQL documention for the
# PQconnectdb function of libpq.
#
# mysql:
# Basic options emulate PostgreSQL option names:
# host, port, user, password, dbname
#
# But also adds some new settings:
# client_flags - See MySQL manual
# ssl_ca, ssl_ca_path - Set either one or both to enable SSL
# ssl_cert, ssl_key - For sending client-side certificates to server
# ssl_cipher - Set minimum allowed cipher security (default: HIGH)
#
# You can connect to UNIX sockets by using host: host=/var/run/mysqld/mysqld.sock
# Note that currently you can't use spaces in parameters.
#
# sqlite:
# The path to the database file.
#
# Examples:
# connect = host=192.168.1.1 dbname=users
# connect = host=sql.example.com dbname=virtual user=virtual password=blarg
# connect = /etc/dovecot/authdb.sqlite
#
#connect = dbname=virtual user=virtual
# Default password scheme.
#
# List of supported schemes is in
# http://wiki.dovecot.org/Authentication/PasswordSchemes
#
#default_pass_scheme = PLAIN-MD5
# Query to retrieve the password.
#
# This query must return only one row with "user" and "password" columns.
# The query can also return other fields which have a special meaning, see
# http://wiki.dovecot.org/PasswordDatabase/ExtraFields
#
# The "user" column is needed to make sure the username gets used with exactly
# the same casing as it's in the database. Note that if you store username and
# domain in separate fields, you most likely want to return a combination of
# them as the "user" column, otherwise the domain gets stripped.
#
# Commonly used available substitutions (see
# http://wiki.dovecot.org/Variables for full list):
# %u = entire userid
# %n = user part of user@domain
# %d = domain part of user@domain
#
# Note that these can be used only as input to SQL query. If the query outputs
# any of these substitutions, they're not touched. Otherwise it would be
# difficult to have eg. usernames containing '%' characters.
#
# Example:
# password_query = SELECT concat(userid, '@', domain) AS user, password FROM users WHERE userid = '%n' AND domain = '%d'
# password_query = SELECT pw AS password FROM users WHERE userid = '%u' AND active = 'Y'
#
#password_query = SELECT userid as user, password FROM users WHERE userid = '%u'
# Query to retrieve the user information.
#
# The query must return only one row. Commonly returned columns are:
# uid - System UID
# gid - System GID
# home - Home directory
# mail - Mail location
#
# Either home or mail is required. uid and gid are required. If more than one
# row is returned or there are missing fields, the login will fail. For a list
# of all fields that can be returned, see
# http://wiki.dovecot.org/UserDatabase/ExtraFields
#
# Examples
# user_query = SELECT home, uid, gid FROM users WHERE userid = '%n' AND domain = '%d'
# user_query = SELECT dir AS home, user AS uid, group AS gid FROM users where userid = '%u'
# user_query = SELECT home, 501 AS uid, 501 AS gid FROM users WHERE userid = '%u'
#
#user_query = SELECT home, uid, gid FROM users WHERE userid = '%u'
# If you wish to avoid two SQL lookups (passdb + userdb), you can use
# userdb prefetch instead of userdb sql in dovecot.conf. In that case you'll
# also have to return userdb fields in password_query prefixed with "userdb_"
# string. For example:
#password_query = SELECT userid as user, password, home as userdb_home, uid as userdb_uid, gid as userdb_gid FROM users WHERE userid = '%u'
driver = mysql
connect = host={mysql_server_host} dbname={mysql_server_database} user={mysql_server_ispconfig_user} password={mysql_server_ispconfig_password}
default_pass_scheme = CRYPT
password_query = SELECT password FROM mail_user WHERE email = '%u' AND disable%Ls = 'n'
user_query = SELECT email as user, maildir as home, CONCAT(maildir, '/Maildir') as mail, uid, gid, CONCAT('maildir:storage=', quota) AS quota, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE email = '%u' AND disable%Ls = 'n'
This diff is collapsed.
......@@ -17,6 +17,8 @@ loglevel=2
module=postfix_mysql
maildir_path=/var/vmail/[domain]/[localpart]
homedir_path=/var/vmail
pop3_imap_daemon=courier
mail_filter_syntax=maildrop
mailuser_uid=5000
mailuser_gid=5000
mailuser_name=vmail
......
......@@ -314,9 +314,15 @@ if($reconfigure_services_answer == 'yes') {
swriteln('Configuring PAM');
$inst->configure_pam();
//** Configure courier
if($conf['dovecot']['installed'] == true) {
//* Configure dovecot
swriteln('Configuring Dovecot');
$inst->configure_dovecot();
} else {
//* Configure courier
swriteln('Configuring Courier');
$inst->configure_courier();
}
//** Configure Spamasassin
swriteln('Configuring Spamassassin');
......@@ -408,6 +414,7 @@ if($reconfigure_services_answer == 'yes') {
if($conf['courier']['courier-imap-ssl'] != '' && is_file($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'].' restart');
if($conf['courier']['courier-pop'] != '' && is_file($conf['init_scripts'].'/'.$conf['courier']['courier-pop'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-pop'].' restart');
if($conf['courier']['courier-pop-ssl'] != '' && is_file($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'].' restart');
if($conf['dovecot']['init_script'] != '' && is_file($conf['init_scripts'].'/'.$conf['dovecot']['init_script'])) system($conf['init_scripts'].'/'.$conf['dovecot']['init_script'].' restart');
}
if($conf['services']['web']) {
if($conf['apache']['init_script'] != '' && is_file($conf['init_scripts'].'/'.$conf['apache']['init_script'])) system($conf['init_scripts'].'/'.$conf['apache']['init_script'].' restart');
......
......@@ -169,6 +169,18 @@ $form["tabs"]['mail'] = array (
'width' => '40',
'maxlength' => '255'
),
'pop3_imap_daemon' => array (
'datatype' => 'VARCHAR',
'formtype' => 'SELECT',
'default' => '20',
'value' => array('courier' => 'Courier', 'dovecot' => 'Dovecot')
),
'mail_filter_syntax' => array (
'datatype' => 'VARCHAR',
'formtype' => 'SELECT',
'default' => '20',
'value' => array('maildrop' => 'Maildrop', 'sieve' => 'Sieve')
),
'mailuser_uid' => array (
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
......
......@@ -59,4 +59,6 @@ $wb["bind_group_error_empty"] = 'BIND group is empty.';
$wb["bind_zonefiles_dir_error_empty"] = 'BIND zonefiles directory is empty.';
$wb["named_conf_path_error_empty"] = 'BIND named.conf path is empty.';
$wb["named_conf_local_path_error_empty"] = 'BIND named.conf.local path is empty.';
$wb["mail_filter_syntax_txt"] = 'Mailfilter Syntax';
$wb["pop3_imap_daemon_txt"] = 'POP3/IMAP Daemon';
?>
\ No newline at end of file
......@@ -19,6 +19,22 @@
<label for="homedir_path">{tmpl_var name='homedir_path_txt'}</label>
<input name="homedir_path" id="homedir_path" value="{tmpl_var name='homedir_path'}" size="40" maxlength="255" type="text" class="textInput" />
</div>
<div class="ctrlHolder">
<p class="label">{tmpl_var name='pop3_imap_daemon_txt'}</p>
<div class="multiField">
<select name="pop3_imap_daemon" id="pop3_imap_daemon" class="selectInput">
{tmpl_var name='pop3_imap_daemon'}
</select>
</div>
</div>
<div class="ctrlHolder">
<p class="label">{tmpl_var name='mail_filter_syntax_txt'}</p>
<div class="multiField">
<select name="mail_filter_syntax" id="mail_filter_syntax" class="selectInput">
{tmpl_var name='mail_filter_syntax'}
</select>
</div>
</div>
<div class="ctrlHolder">
<label for="mailuser_uid">{tmpl_var name='mailuser_uid_txt'}</label>
<input name="mailuser_uid" id="mailuser_uid" value="{tmpl_var name='mailuser_uid'}" size="10" maxlength="255" type="text" class="textInput formLengthHalf" />
......
......@@ -151,14 +151,14 @@ $form["tabs"]['mailuser'] = array (
'disableimap' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => '0',
'value' => array(1 => '1',0 => '0')
'default' => 'n',
'value' => array(1 => 'y',0 => 'n')
),
'disablepop3' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'y',
'value' => array(1 => '1',0 => '0')
'default' => 'n',
'value' => array(1 => 'y',0 => 'n')
),
##################################
# ENDE Datatable fields
......
......@@ -250,6 +250,17 @@ class page_action extends tform_actions {
}
} // endif spamfilter policy
// Set the fields for dovecot
if(isset($this->dataRecord["email"])) {
$disableimap = ($this->dataRecord["disableimap"])?'y':'n';
$disablepop3 = ($this->dataRecord["disablepop3"])?'y':'n';
$disabledeliver = ($this->dataRecord["postfix"] == 'y')?'n':'y';
$disablesmtp = ($this->dataRecord["postfix"] == 'y')?'n':'y';
$sql = "UPDATE mail_user SET disableimap = '$disableimap', disablepop3 = '$disablepop3', disablesmtp = '$disablesmtp', disabledeliver = '$disabledeliver' WHERE mailuser_id = ".$this->id;
$app->db->query($sql);
}
}
function onAfterUpdate() {
......@@ -281,6 +292,17 @@ class page_action extends tform_actions {
} // endif spamfilter policy
}
// Set the fields for dovecot
if(isset($this->dataRecord["email"])) {
$disableimap = ($this->dataRecord["disableimap"])?'y':'n';
$disablepop3 = ($this->dataRecord["disablepop3"])?'y':'n';
$disabledeliver = ($this->dataRecord["postfix"] == 'y')?'n':'y';
$disablesmtp = ($this->dataRecord["postfix"] == 'y')?'n':'y';
$sql = "UPDATE mail_user SET disableimap = '$disableimap', disablepop3 = '$disablepop3', disablesmtp = '$disablesmtp', disabledeliver = '$disabledeliver' WHERE mailuser_id = ".$this->id;
$app->db->query($sql);
}
}
}
......
......@@ -92,7 +92,7 @@ class page_action extends tform_actions {
$found = false;
foreach($lines as $line) {
$line = trim($line);
$line = rtrim($line);
if($line == '### BEGIN FILTER_ID:'.$this->id) {
$skip = true;
$found = true;
......@@ -117,6 +117,54 @@ class page_action extends tform_actions {
function getRule() {
global $app,$conf;
$app->uses("getconf");
$mailuser_rec = $app->db->queryOneRecord("SELECT server_id FROM mail_user WHERE mailuser_id = ".intval($this->dataRecord["mailuser_id"]));
$mail_config = $app->getconf->get_server_config(intval($mailuser_rec["server_id"]),'mail');
if($mail_config['mail_filter_syntax'] == 'sieve') {
// #######################################################
// Filter in Sieve Syntax
// #######################################################
$content = '';
$content .= '### BEGIN FILTER_ID:'.$this->id."\n";
//$content .= 'require ["fileinto", "regex", "vacation"];'."\n";
$content .= 'if header :regex ["'.strtolower($this->dataRecord["source"]).'"] ["';
$searchterm = preg_quote($this->dataRecord["searchterm"]);
if($this->dataRecord["op"] == 'contains') {
$content .= ".*".$searchterm;
} elseif ($this->dataRecord["op"] == 'is') {
$content .= $searchterm."$";
} elseif ($this->dataRecord["op"] == 'begins') {
$content .= " ".$searchterm."";
} elseif ($this->dataRecord["op"] == 'ends') {
$content .= ".*".$searchterm."$";
}
$content .= '"] {'."\n";
if($this->dataRecord["action"] == 'move') {
$content .= ' fileinto "'.$this->dataRecord["target"].'";' . "\n";
} else {
$content .= " discard;\n";
}
$content .= " stop;\n}\n";
$content .= '### END FILTER_ID:'.$this->id."\n";
} else {
// #######################################################
// Filter in Maildrop Syntax
// #######################################################
$content = '';
$content .= '### BEGIN FILTER_ID:'.$this->id."\n";
......@@ -175,6 +223,8 @@ if ( ".'$RETURNCODE'." != 1 )
$content .= '### END FILTER_ID:'.$this->id."\n";
}
return $content;
}
......
require ["fileinto", "regex", "vacation"];
<tmpl_if name="move_junk" op="==" value="y">
# 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;
}