You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
691 B

#!/bin/bash
HOME=/root
SOGOWL=$(/sbin/e-smith/db/configuration getprop sogod AutoWhiteList || $(echo no))
if [ "$SOGOWL" != 'yes' ]; then
exit 0
fi
/usr/bin/mysql <<'EOF' | grep -iE "^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$" | sed -e 's/^/whitelist_from /' > /etc/mail/spamassassin/sogo_whitelist
connect sogo;
SELECT CONCAT(
'SELECT * FROM (SELECT c_mail FROM ',
GROUP_CONCAT(tb SEPARATOR ' UNION SELECT c_mail FROM '),
') AS emails ORDER BY c_mail'
)
INTO @mailquery FROM
(
SELECT TABLE_NAME tb
FROM INFORMATION_SCHEMA.COLUMNS
WHERE column_name LIKE 'c_mail'
AND TABLE_SCHEMA='sogo'
) AS tbls;
PREPARE stmt FROM @mailquery;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
EOF