Page 1 of 1
[URGENT] Requeue (process again) all the email blocked in the last 12 hours
Posted: 14 Sep 2018 09:23
by fbessone
Hello guys,
tonight my EFA blocked all emails with this error:
MailScanner: Message attempted to kill MailScanner
I solved the error, clamAV related: but now i want to process again all the blocked emails to deliver the legimit ones.
How can i do it? There are thousands of email, cant do it manually via web interface ..
Thank you in advance
Re: [URGENT] Requeue (process again) all the email blocked in the last 12 hours
Posted: 14 Sep 2018 10:39
by shawniverson
Hi,
You will need to use a script to accomplish this. The process..
1) Gather all messages and place in a directory
2) Use a script to iterate through the files, extract the original recipient address, and call /usr/sbin/sendmail to requeue the message.
Code: Select all
#!/bin/bash
pathname='/path/to/files/'
for filename in $pathname; do
if [[ -f "$filename" ]]; then
# extract orig recip
recip=$(grep "^[[:space:]]*for" $pathname$filename | head -n1 | awk '{print $2}' | sed 's/^<//' | sed 's/>$//' | sed 's/>;$//')
if [[ -n "$recip" ]]; then
sendmail -G -i $recip < $pathname$filename
fi
fi
done
Re: [URGENT] Requeue (process again) all the email blocked in the last 12 hours
Posted: 17 Dec 2018 09:58
by p88
Hi,
i got the same situation, needed to resend incoming mails ( which where at the quarantine folders) to the local mail server.
The script was above was'nt working, i used this script:
pathname='/var/spool/MailScanner/quarantine/20181103/nonspam'
for filename in "$pathname"/*
do
/usr/sbin/sendmail.postfix -t < "$filename"
done
it should be adopted ( sendmail.postfix is different to sendmail) and it would be great to have a menu point somewhere to just select the date to resend emails from the nonspam folders to the internal users.
Re: [URGENT] Requeue (process again) all the email blocked in the last 12 hours
Posted: 16 Jan 2020 01:11
by donhw
Don't know if v4 breaks the script or what. Here is what I did to get it working. Improvements would be welcome.
Code: Select all
#!/bin/bash
#trap "set +x; sleep 1 ; set -x" DEBUG
filecount=0
pathname="/root/quarentine/*" # Path to directory
#echo "$pathname" # debug
#ls $pathname # debug
for filename in $pathname; do
#echo "file name $filename" # debug
if [[ -e $(eval echo $filename) ]]; then
filecount=$[ $filecount +1 ]
# extract orig recip
recip=$(grep "^[[:space:]]*for" $filename | head -n1 | awk '{print $2}' | sed 's/^<//' | sed 's/>$//' | sed 's/>;$//')
#echo "$recip" # debug
if [[ -n "$recip" ]]; then
#echo "$pathname$filename" # debug
sendmail -G -i $recip < $filename
fi
fi
echo "Prosessed $filecount files"
done
Left debug in there in case someboby needs it.
Thanks