Exim cheat sheet

Posted: May 2, 2013 in Mail Servers

1. To remove all mails from exim queue :

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

2. Deleting Frozen Mails:

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

exiqgrep -z -i | xargs exim -Mrm

3. 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. ).

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

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

5. To flush the mail queue:

exim -qff

/usr/sbin/exim -qff

exim -qf – Force another queue run

6. To clear spam mails from Exim Queue:

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

7.To clear frozen mails from Exim Queue.

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

8. 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

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

exim -bp |exiqsumm

10. 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

11. 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

12. 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

13. To forcefully deliver mails of a particular domain :

exim -v -Rff domain

14. To find the number of frozen mails in queue :

exim -bpr | grep frozen | wc -l

15. To find the number of mails in Queue:

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

exim -bpc

16. To view the log for the message :

exim -Mvl message ID

17. To show the mail in queue for $name

exim -bp|grep $name

18. To view the message header

exim -Mvh $MSGID

19. To view the message body

exim -Mvb $MSGID

20. To forcefully deliver the message

exim -M $MSGID

21. To view the transact of the message

exim -v -M $MSGID

22. To remove message without sending any error message

exim -Mrm messageID

23. To check the mails in the queue

exim -bp

24. To check the syntactic errors

exim -C /config/file.new -bV

25. To delete mails for a particular domain

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

26. 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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s