[URGENT] Requeue (process again) all the email blocked in the last 12 hours

General eFa discussion
Post Reply
fbessone
Posts: 10
Joined: 18 Feb 2015 18:02

[URGENT] Requeue (process again) all the email blocked in the last 12 hours

Post by fbessone » 14 Sep 2018 09:23

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

User avatar
shawniverson
Posts: 3087
Joined: 13 Jan 2014 23:30
Location: Indianapolis, Indiana USA
Contact:

Re: [URGENT] Requeue (process again) all the email blocked in the last 12 hours

Post by shawniverson » 14 Sep 2018 10:39

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
Version eFa 4.0.2 now available!

p88
Posts: 4
Joined: 12 Feb 2018 08:41

Re: [URGENT] Requeue (process again) all the email blocked in the last 12 hours

Post by p88 » 17 Dec 2018 09:58

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.

donhw
Posts: 1
Joined: 14 Jan 2020 19:17

Re: [URGENT] Requeue (process again) all the email blocked in the last 12 hours

Post by donhw » 16 Jan 2020 01:11

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

Post Reply