Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Exim Mail Que

Discussion in 'E-mail Discussion' started by SoftmegUK, May 17, 2004.

  1. SoftmegUK

    SoftmegUK Well-Known Member

    Joined:
    Feb 13, 2002
    Messages:
    372
    Likes Received:
    0
    Trophy Points:
    316
    Location:
    UK
    Hiya,

    I need to remove a lot of emails from the mail que that are to be sent to a certain domain and I have seen the command to do it but cannot remember it off the top of my head... hope someone has the answer!

    Cheers...
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. cyon

    cyon Well-Known Member
    PartnerNOC

    Joined:
    Jan 15, 2003
    Messages:
    320
    Likes Received:
    0
    Trophy Points:
    166
  3. rusko

    rusko Member

    Joined:
    Nov 20, 2002
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    151
    there is no 'command' per se. this script will do the job.

    Code:
    #!/bin/bash
    
    CDIR=`date +%m%d%H%M%S`
    echo -e "Moving to /var/spool/exim/deleted/$CDIR\n"
    mkdir -p "/var/spool/exim/deleted/$CDIR"
    echo -e "$1\n" > /var/spool/exim/deleted/$CDIR/.job  
    
    MCOUNT=0
    COUNT=0
    echo -e "Moving..."
    for fname in $( ls /var/spool/exim/input ); do
    let "COUNT += 1"
    grep "$1" /var/spool/exim/input/$fname > /dev/null
    if [ $? -eq 0 ]; then
    fname=`echo $fname | sed s/-.$// -`
    echo "$fname"
    let "MCOUNT += 1"
    #echo -n "."
    cp /var/spool/exim/input/$fname* /var/spool/exim/deleted/$CDIR
    exim -Mrm $fname
    fi
    done
    echo -e "$MCOUNT/$COUNT\n" >> /var/spool/exim/deleted/$CDIR/.job
    echo -e "\n---\nMoved $MCOUNT out of $COUNT messages\n"  
    sorry for the horrible formatting.

    write it out to, say, /usr/bin/cleanq.sh
    chmod a+x `which cleanq.sh`
    nohup bash /usr/bin/cleanq.sh "pattern you want to match" &

    voila. you are going to end up with the matching emails being written out to /var/spool/exim/deleted/$dateinsecssinceepoch

    not very efficient, but works ok for up to about 20-30k messages in the spool. if you can be bothered, do the pattern stripping op in bash instead of spawning sed and only match the data or header. i've got a proprietary version coded in c, so dont expect me to fix this up =]

    cheers,
    paul
     
    #3 rusko, May 19, 2004
    Last edited: May 19, 2004
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice