Tag: eximrm

  • eximrm

    Here is a bash script to delete mails in exim mail queue. Helpful when you have lot of spam mails in mail queue.

    Create file

    vi /usr/local/bin/eximrm
    

    Add

    #!/bin/bash
     
    exim -bpu | awk '{print $3}' | xargs exim -Mrm
    

    Make it executable

    chmod 755 /usr/local/bin/eximrm
    

    Monitor Server Mail Queue

    Run following script every 1 hour to monitor/alert email queue

    #!/bin/bash
    
    [email protected]
    _limit=250
    
    _result="/tmp/serverok-exim-mailq.txt"
    _queue="`/usr/sbin/exim -bpc`"
    
    if [ "$_queue" -ge "$_limit" ]; then
        echo "Current queue is: $_queue" > $_result
        echo "Summary of Mail queue" >> $_result
        echo "`/usr/sbin/exim -bp | /usr/sbin/exiqsumm`" >> $_result
        mail -s "Number of mails on `hostname` : $_queue" $_mail_user < $_result
        cat $_result
    fi
    
    rm -f $_result