Saturday, September 28, 2013

Exim cheat sheet

To remove all mails from exim queue :

rm -rf /var/spool/exim/input/*

Deleting Frozen Mails:

exim -bpr | grep frozen | awk {‘print $3′} | xargs exim -Mrm

exiqgrep -z -i | xargs exim -Mrm

To delete only frozen messages older than a day:

exiqgrep -zi -o 86400 | xargs exim -Mrm

where you can change 86400 depending on the time frame you want to keep.( 1 day = 86400 seconds. ).

To forcefully deliver mails in queue, use the following exim command:

exim -bpru |awk ‘{print $3}’ | xargs -n 1 -P 40 exim -v -M

To flush the mail queue:

exim -qff

/usr/sbin/exim -qff

exim -qf – Force another queue run

To clear spam mails from Exim Queue:

grep -R -l [SPAM] /var/spool/exim/msglog/*|cut -b26-|xargs exim -Mrm

To clear frozen mails from Exim Queue.

grep -R -l ‘*** Frozen’ /var/spool/exim/msglog/*|cut -b26-|xargs exim -Mrm

To clear mails from Exim Queue for which recipient cannot not be verified.

grep -R -l ‘The recipient cannot be verified’ /var/spool/exim/msglog/*|cut -b26-|xargs exim -Mrm

To find exim queue details. It will show ( Count Volume Oldest Newest Domain ) details.

exim -bp |exiqsumm

To remove root mails from exim queue :

When mail queue is high due to root mails, and you only need to remove the root mails and not any other valid mails.

exim -bp |grep “”|awk ‘{print $3}’|xargs exim -Mrm

Replace “HOSTNAME” with server hostname

To remove nobody mails from exim queue :

When you need to clear nobody mails, you can use the following command.

exiqgrep -i -f nobody@HOSTNAME | xargs exim -Mrm (Use -f to search the queue for messages from a specific sender)

exiqgrep -i -r nobody@HOSTNAME | xargs exim -Mrm (Use -r to search the queue for messages for a specific recipient/domain)

Replace “HOSTNAME” with server hostname

Run a pretend SMTP transaction from the command line, as if it were coming from the given IP address. This will display Exim’s checks, ACLs, and filters as they are applied. The message will NOT actually be delivered.

# exim -bh

To forcefully deliver mails of a particular domain :

exim -v -Rff domain

To find the number of frozen mails in queue :

exim -bpr | grep frozen | wc -l

To find the number of mails in Queue:

exim -bpr | grep “<" | wc -l

exim -bpc

To view the log for the message :

exim -Mvl message ID

To show the mail in queue for $name

exim -bp|grep $name

To view the message header

exim -Mvh $MSGID

To view the message body

exim -Mvb $MSGID

To forcefully deliver the message

exim -M $MSGID

To view the transact of the message

exim -v -M $MSGID

To remove message without sending any error message

exim -Mrm messageID

To check the mails in the queue

exim -bp

To check the syntactic errors

exim -C /config/file.new -bV

To delete mails for a particular domain

exim -bp | grep "” | awk {‘print $3′} | xargs exim -Mrm

To view number of mails in queue for each domain

exim -bp | exiqsumm | grep -v ‘\-\-’ | grep -v ‘Volume’ | grep -v ‘^$’ | sort -bg | awk ‘{print “Volume: ” $1 ” \t Domain: ” $5}’A

Run the following command to pull the most used mailing script’s location from the Exim mail log:

grep cwd /var/log/exim_mainlog | grep -v /var/spool | awk -F”cwd=” ‘{print $2}’ | awk ‘{print $1}’ | sort | uniq -c | sort -n

No comments:

Post a Comment