I recently had some fun with sendmail. Yes, there are companies out there who still use it.
The fun I had was that our upstream MX for the internal sendmail hosts were blocking us for spam. This was due to a bulkmail mail sent out to 22500 people. Who would have thought that 22500 EMails being sent within 20 minutes would be considered as spam?
Anyway, once the upstream MX was dealt with and stopped blocking us, we had the need to force through the delivery of a handful of VIP EMails and the last time I had used sendmail was a good 4 years ago and I could not remember off the top of my head the command to force a specific EMail through but remembered that you could. Don’t you hate that?
After some searching, I found that the command to force a specific EMail to deliver out of the thousands that currently exist in the queue is:
sendmail -v -o MinQueueAge=0 -qI<mailq id>
To find all the EMails sent by the person in question, you just need to go to the mqueue directory and grep the EMail address out of the qf files:
cd /var/spool/mqueue grep <email address> qf*
With the list of files returned by grep, all you need top do is drop the qf from the beginning of the file name to get the mailq id of the EMail(s) you are after and run the above sendmail command against it.
Another problem you could potentially run into if your mailq starts to grow is the inability of grep to accept ‘grep <email address> qf*’ due to the amount of files in the directory causing grep to complain that there are to many arguments. A simple for loop can be used to get around this problem.
for i in `ls qf*`; do grep <email address> $i; done
This can be entered on the command line directly, no need to create a .sh file to run it from.