Commit 829cb747 authored by Claudemir Todo Bom's avatar Claudemir Todo Bom

* support different mailbox formats and set sdbox as default

parent 0f6a56e4
Pipeline #262 passed with stage
in 1 minute and 28 seconds
......@@ -26,7 +26,7 @@ if [ $MONITOR == $LOCAL_PART@$DOMAIN ] ; then
exit 0
fi
MONITORDIR=$(echo "select maildir from users where address='$MONITOR';" | mysql -h ${WW_ISP_HOST} -p${WW_ISP_PASS} -r -N -u${WW_ISP_USER} ${WW_ISP_DB})
MONITORDIR=$(echo "SELECT maildir FROM users WHERE address='${MONITOR}' AND mailformat IN ( 'dbox' , 'sdbox' , 'mdbox' );" | mysql -h ${WW_ISP_HOST} -p${WW_ISP_PASS} -r -N -u${WW_ISP_USER} ${WW_ISP_DB})
if ! [ $MONITORDIR ] ; then
exit 0
fi
......@@ -35,20 +35,19 @@ if ! [ -d $MONITORDIR ] ; then
exit 0
fi
if ! [ -d $MONITORDIR/.monitor ] ; then
/usr/bin/maildirmake.maildrop -f monitor $MONITORDIR &> /dev/null
fi
#if ! [ -d $MONITORDIR/.monitor.$LOCAL_PART ] ; then
# /usr/bin/maildirmake.maildrop -f monitor.$LOCAL_PART $MONITORDIR &> /tmp/monitor.log
# echo ${BASEFOLDER}monitor.$LOCAL_PART >> ${MONITORDIR}/${SUBSCRIPTIONFILE}
#fi
if ! [ -d $MONITORDIR/.monitor.$LOCAL_PART ] ; then
/usr/bin/maildirmake.maildrop -f monitor.$LOCAL_PART $MONITORDIR &> /tmp/monitor.log
echo ${BASEFOLDER}monitor.$LOCAL_PART >> ${MONITORDIR}/${SUBSCRIPTIONFILE}
fi
MIDFILE="${MONITORDIR}/monitor-${LOCAL_PART}@${DOMAIN}-mid.txt"
if [ -f $MONITORDIR/.monitor.$LOCAL_PART/mid.txt ] ; then
if grep $MESSAGEID $MONITORDIR/.monitor.$LOCAL_PART/mid.txt; then
if [ -f "${MIDFILE}" ] ; then
if grep ${MESSAGEID} "${MIDFILE}"; then
exit 0
fi
fi
echo $MESSAGEID >> $MONITORDIR/.monitor.$LOCAL_PART/mid.txt
cat $MAILFILE | /usr/sbin/deliverquota.maildrop $MONITORDIR/.monitor.$LOCAL_PART &> /dev/null
echo ${MESSAGEID} >> "${MIDFILE}"
cat $MAILFILE | /usr/lib/dovecot/deliver -d "${MONITOR}" -o "plugin/sieve=file:~/monitorsieve" -m "monitor/${DOMAIN}/${LOCAL_PART}" -e &> /dev/null
exit 0
......@@ -5,7 +5,7 @@ log_timestamp = "%Y-%m-%d %H:%M:%S "
mail_location = maildir:%h
mail_privileged_group = mail
mail_plugins = quota
mail_attribute_dict = file:%h/dovecot-attributes
mail_attribute_dict = file:/%h/dovecot-attributes
imap_metadata = yes
imap_capability = +SPECIAL-USE
......
......@@ -113,7 +113,7 @@ password_query = SELECT address as user , crypt as password FROM users WHERE add
# 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'
user_query = SELECT maildir as home , 8 as uid , 8 as gid , concat("*:storage=" , quota , "M") as quota_rule FROM users,domains WHERE users.address = '%u' AND domains.domain=substring_index(address,'@',-1) AND users.mail>0 AND users.active>0
user_query = SELECT maildir AS home , 8 AS uid , 8 AS gid , CONCAT("*:storage=" , quota , "M") AS quota_rule , CONCAT(mailformat, ":" , maildir) AS mail FROM users,domains WHERE users.address = '%u' AND domains.domain=substring_index(address,'@',-1) AND users.mail>0 AND users.active>0
# 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
......
......@@ -1148,21 +1148,18 @@ mailbox_host:
### ALL DIRECTORS FROM NOW ON MUST HAVE verify_recipient = false / THEY ARE USED ONLY FOR DELIVERY
mysql_spam_users:
driver = redirect
allow_defer
allow_fail
dovecot_spam_users:
driver = accept
verify_recipient = false
local_part_suffix = +*
local_part_suffix_optional
data = ${lookup mysql {SELECT CONCAT(maildir,".Junk/") as maildir FROM users where address = unalias('$local_part@$domain') and maildir like '%/' and mail>0 and active>=0;}}
headers_add = X-WW-spamheader: score=${sg{$header_X-Spam-WW-Score:}{^([^. ]*).*\$}{\$1}} threshold=${acl_m8}
condition = ${lookup mysql {SELECT address FROM users where address = unalias('$local_part@$domain') and mail>0 and active>=0;}}
condition = ${if and {{def:acl_m8}{def:h_X-Spam-WW-Score:}{>={${sg{$header_X-Spam-WW-Score:}{^([^. ]*).*\$}{\$1}}}{${acl_m8}}}}{yes}{no}}
directory_transport = address_spam_directory
file_transport = address_file
group = mail
pipe_transport = address_pipe
transport = dovecot_spam_delivery
user = mail
group = mail
retry_use_local_part
dovecot_mysql_users:
driver = accept
......@@ -1267,15 +1264,19 @@ shadow_transport:
user = mail
address_spam_directory:
driver = appendfile
check_string =
maildir_format
maildir_use_size_file = false
maildir_tag = ,S=$message_size
message_prefix = ""
message_suffix = ""
dovecot_spam_delivery:
driver = pipe
command = /usr/lib/dovecot/deliver -d "${lookup mysql{select unalias('$local_part@$domain')}}" -o "plugin/sieve=file:~/sieve;active=~/sieve/junk.sieve" -m Junk -f $sender_address -a $original_local_part@$original_domain
message_prefix =
message_suffix =
delivery_date_add
envelope_to_add
return_path_add
log_output
transport_filter = /usr/local/bin/fancybounce.py
user = mail
group = mail
temp_errors = 64 : 69 : 70: 71 : 72 : 73 : 74 : 75 : 78
# This transport is used for handling autoreplies generated by the filtering
......
START TRANSACTION;
ALTER TABLE `users` ADD `mailformat` VARCHAR(10) NOT NULL DEFAULT 'sdbox' AFTER `name`;
UPDATE users SET mailformat="maildir";
COMMIT;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment