How Do You Get a List of Mail Queue IDs and Nothing Else?

Problem scenario
You use the mailq command. You see several emails have timed out. These emails are essentially in an "outbox" and a future delivery attempt is in the near future. How do you produce a list of the mail queue IDs by themselves?

Solution
If you want a list of the mail queue IDs in the queue, run this:
mailq | awk '{print $1}' | grep -v '[[:punct:]]' | sort | uniq

Leave a comment

Your email address will not be published. Required fields are marked *