|
||||||||
|
||||||||
|
|
Công Cụ | Xếp Bài |
15-11-2009, 01:41 PM | #1 | ||||
Guest
Trả Lời: n/a
|
View the Sendmail or Postfix mail queue!
View the Sendmail or Postfix mail queue! and Empty Postfix Mail Queue
Concept Be able to view the mail queue to determine if any mail is stuck in the queue, and if necessary, ask the MTA to reprocess or flush the queue. Introduction As noted in section Determine which MTA is being used on the system, the BSD systems use Sendmail or Postfix by default for handling mail. The mail queue can be displayed using the mailq(1) utility. The queue listing identifies messages that are still queued (not successfully sent or delivered yet). The output includes MTA's internal message identifier, the size of the message, the date and time the message was accepted into the queue, the sender's envelope address, and the recipient address(es), as well as a reason of failure for messages that have permanently failed. When using Postfix, if the mailq(1) utility is not setup, use postqueue -p to display the traditional sendmail-style queue listing. To make MTA attempt to deliver all queued mail issue commands: sendmail -q for Sendmail and postqueue -f for Posftix. Examples Following are two examples of mailq(1) output. First when used with Sendmail: ""# mailq ""/var/spool/mqueue (1 request) ""-----Q-ID----- --Size-- -----Q-Time----- ------------Sender/Recipient----------- ""l0ID36a2085983 524 Thu Jan 18 14:03 <[email protected]> "" (Deferred: Operation timed out with otherdomain.com.) "" <[email protected]> "" Total requests: 1 And an example when used with Postfix: ""# mailq ""-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient------- ""D184ACAB55 709 Fri Jan 19 20:50:08 [email protected] ""(delivery temporarily suspended: connect to mail.otherdomain.com[10.0.0.11]: Connection refused) "" [email protected] "" ""-- 709 bytes in 1 Request. Practice Exercises
http://bsdwiki.reedmedia.net/wiki/Ta..._Contents.html Empty Postfix Mail Queue This command will delete one specific email from the mailq (taken from the postsuper man page) mailq | tail +2 | grep -v '^ *(' | awk 'BEGIN { RS = "" } { if ($8 == "[email protected]" && $9 == "") print $1 } ' | tr -d '*!' | postsuper -d - I use a few scripts that check the status of our servers and email/page me if they don't respond. This led to a problem when I was offline for one reason or another. I would get a ton of messages sent to the postfix queue which would all be sent out when I reconnected to the internet. Deleting the postfix mail Queue is suprisingly easy: sudo postsuper -d ALL This command will delete all messages in the Postfix queue. If you need more selective deleting, this can be done as well, use 'man postsuper' to find out all of the available options. Postfix Flush the Mail Queue Traditionally you use the "sendmail -q" command to flush mail queue under Sendmail MTA. Under Postfix MTA, just enter the following command to flush the mail queue: # postfix flush OR # postfix -f To see mail queue, enter: # mailq To remove all mail from the queue, enter: # postsuper -d ALL To remove all mails in the deferred queue, enter: # postsuper -d ALL deferred postfix-delete.pl script Following script deletes all mail from the mailq which matches the regular expression specified as the first argument (Credit: ??? - I found it on old good newsgroup)
./postfix-delete.pl fackspamdomain.com Delete all queued messages that contain the word "xyz" in the e-mail address: ./postfix-delete.pl xyz Updated for accuracy. |
||||
|
|