Whenever sendmail has to deliver mails to other hosts which cannot be reached at that time, the messages are kept in the queue and are marked as “Deferred: Connection timed out”. Although the other hosts could be reached again and you want to tell sendmail to flush the mail queue, the command
sendmail -q -v
does not really try to reconnect to these hosts and still assumes that the connection timed out. The reason is that the hoststatus is cached, per default for a period of 30 minutes. Using
sendmail -OTimeout.hoststatus=0m -q -v
you can re-run the mail queue and force sendmail to reconnect to the hosts.
Alternatively, if you want to do a selective flush on perticular domain or user or recepitience mail to delete, use this command
sendmail -qS -v apache # it will delete all mail from *@apache
sendmail -qR -v a.com # it will delete all mail destined for recepient at user of a.com