diff --git a/bin/vmail-mboxes-add.sh b/bin/vmail-mboxes-add.sh index fa9679d..a0a9cc5 100755 --- a/bin/vmail-mboxes-add.sh +++ b/bin/vmail-mboxes-add.sh @@ -13,13 +13,14 @@ help() echo "$thisfilename" echo "Add email account to vmail system" echo "" - echo "usage: $thisfilename -e -p [-q ] [-s <0|1>] [-h]" + echo "usage: $thisfilename -e -p [-q ] [-s <0|1>] [-j <0|1|2>] [-h]" echo "" echo " -h Print this help." echo " -e Email address to add." echo " -p Unencrypted Password for new email address." echo " -q Set mailbox quota in GB, otherwise default for this domain is used. NULL means no limit." echo " -s <0|1> Status. 1 for enabled, 0 for disabled. Default is in db structure and is normally set to 1." + echo " -j <0|1|2> Filter Junk/Spam messages. 0 = not filtering. 1 = filter Junk only. 2 = filter Junk & Spam. Default is 2." } vmail:getoptions "$@" @@ -53,6 +54,9 @@ if [ "$rowcount" -eq '0' ] ; then if [[ -n $status ]] ; then dbcmd="$dbcmd, status=\"$status\"" fi + if [[ -n $filter ]] ; then + dbcmd="$dbcmd, filter=\"$filter\"" + fi if [ -z "$quota" ] ; then # get mbox_quota_default from domains table quota=`mysql --defaults-extra-file=$MYSQL_CONNECTION_INFO_FILE -s -r -N -e "SELECT mbox_quota_default from vm_domains WHERE domain='$domain';"` diff --git a/bin/vmail-mboxes-mod.sh b/bin/vmail-mboxes-mod.sh index e0211f9..592f95a 100755 --- a/bin/vmail-mboxes-mod.sh +++ b/bin/vmail-mboxes-mod.sh @@ -20,6 +20,7 @@ help() echo " -p Set new password." echo " -q Set mailbox quota in GB, otherwise default for this domain is used. NULL means no limit." echo " -s <0|1> 1 for enabled, 0 for disabled. Default is in db structure and is normally set to 1." + echo " -j <0|1|2> Filter Junk/Spam message. 0 = not filtering. 1 = filter Junk only. 2 = filter Junk & Spam. Default is 2." exit } @@ -71,6 +72,14 @@ if [ ! -z "$status" ]; then dbset="$dbset status=\"$status\"" fi +# check for junk filter update +if [ ! -z "$filter" ]; then + if [ ! -z "$dbset" ]; then + dbset="$dbset," + fi + dbset="$dbset filter=\"$filter\"" +fi + if [ -n "$dbset" ]; then # build query diff --git a/bin/vmail.sh b/bin/vmail.sh index 9950c04..2f345b4 100755 --- a/bin/vmail.sh +++ b/bin/vmail.sh @@ -85,7 +85,7 @@ function vmail::yesno() { function vmail:getoptions () { local OPTIND - while getopts "ha:b:d:e:f:gcp:q:s:tk:f:gl:m:vx" opt ; do + while getopts "ha:b:d:e:f:gj:cp:q:s:tk:gl:m:vx" opt ; do case "${opt}" in h ) # display help and exit help @@ -159,6 +159,9 @@ function vmail:getoptions () { g ) # glob (wildcard) search glob=${OPTARG,,} ;; + j ) # Filter Junk + filter=${OPTARG} + ;; k ) # keep keep=${OPTARG} if [[ $keep != "0" ]] && [[ $keep != "1" ]]; then diff --git a/vmail.sql b/vmail.sql index 4c6985d..d55937e 100644 --- a/vmail.sql +++ b/vmail.sql @@ -179,6 +179,7 @@ CREATE TABLE IF NOT EXISTS `vm_mboxes` ( `passwd` char(128) NOT NULL, `status` tinyint(1) NOT NULL DEFAULT 1, `quota` int(10) UNSIGNED DEFAULT NULL, + `filter` tinyint(1) NOT NULL DEFAULT 2, PRIMARY KEY (`id`), KEY `email` (`domain_id`,`mbox`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;