Wednesday, December 10, 2014

Exim mail server useful commands

Common Exim Commands:

exim -bpc                       - Print a count of the messages in the queue
exim -bp                       - Print a listing of the messages in the queue (time queued, size, message-id,
exim -M emailID                 - force delivery of one message
exim -Mvl messageID             - View Log for message
exim -Mvb messageID             - View Body for message

Clear the mail queue in terminal:

exim -bpr | grep '<>' | awk '{print $3}' | xargs exim -Mrm

exim -bp | awk '/^ *[0-9]+[mhd]/{print "exim -Mrm " $3}' | bash

Check how may frozen emails in the queue:

exim -bpr | grep frozen | xargs exim -Mrm wc -l

How to Check the total number of emails sent to particular domain in mail queue ?

exim -bp | exiqsumm | grep 'gmail.com'

Find spammers:

grep "cwd=" /var/log/exim_mainlog|awk '{for(i=1;i<=10;i++){print $i}}'|sort|uniq -c|grep cwd|sort -n

To display the IP and no of tries done bu the IP to send mail but rejected by the server:

tail -3000 /var/log/exim_mainlog |grep 'rejected RCPT' |awk '{print$4}'|awk -F\[ '{print $2}'|awk -F\] '{print $1} '|sort | uniq -c | sort -k 1 -nr | head -n 5

No comments:

Post a Comment