I've made a script to add rules to the Spam Filter automatically so I don't have to waste weeks to update many accounts by hand.
It's a bash script that uses the reseller user/pass impersonating the user accounts.
It works.
The problem is not adding, is deleting.
The same rules added by my scipt cannot be deleted by the same script (and no error).
I've tried different strategies: by value, by index, all at once, one by one... nothing to do.
This is the specific part of the script that manages the deletion by value
It returns:
Deleting domain=domain1.com
Deleting domain=test.it
Deleting domain=shhht.net
and the API returns
error=0&text=Filter%28s%29%20removed&details=
for every deletion. So all OK.
It looks like it works but actually does nothing. There is no error.
Any idea why I can't delete the rules the same script can add without problems? It's a bug?
It's a bash script that uses the reseller user/pass impersonating the user accounts.
It works.
The problem is not adding, is deleting.
The same rules added by my scipt cannot be deleted by the same script (and no error).
I've tried different strategies: by value, by index, all at once, one by one... nothing to do.
This is the specific part of the script that manages the deletion by value
Code:
# 2. Delete each current filter
CURRENT=$(curl -s -k -u "$RESELLER|$u:$RESELLERPASS" \
"$DA_HOST/CMD_API_EMAIL_FILTER?domain=$DOMAIN&api=yes" |
perl -MURI::Escape -ne 'print uri_unescape($_)')
# Extract lines with both type and value
grep -oP '[0-9]+=type=[^&]+&value=[^&]+' <<< "$CURRENT" | while IFS='=' read -r idx rest; do
type=$(echo "$rest" | sed -n 's/.*type=\([^&]*\).*/\1/p')
value=$(echo "$rest" | sed -n 's/.*value=\([^&]*\).*/\1/p')
echo "Deleting $type=$value"
curl -s -k -u "$RESELLER|$u:$RESELLERPASS" \
-d "action=delete" \
-d "domain=$DOMAIN" \
-d "type=$type" \
-d "value=$value" \
"$DA_HOST/CMD_API_EMAIL_FILTER" # > /dev/null
done
It returns:
Deleting domain=domain1.com
Deleting domain=test.it
Deleting domain=shhht.net
and the API returns
error=0&text=Filter%28s%29%20removed&details=
for every deletion. So all OK.
It looks like it works but actually does nothing. There is no error.
Any idea why I can't delete the rules the same script can add without problems? It's a bug?