Chia Sẽ Kinh Nghiệm Về IT



Tìm Kiếm Với Google
-


Gởi Ðề Tài Mới  Gửi trả lời
 
Công Cụ Xếp Bài
Tuổi 15-11-2009, 01:41 PM   #1
hoctinhoc
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

  1. When logged into your mail server, see the output of postqueue(1) and/or mailq(1) commands (depending on which MTA is used).

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)



Trích dẫn:
#!/usr/bin/perl

$REGEXP = shift || die "no email-adress given (regexp-style, e.g. bl.*\@yahoo.com)!";

@data = qx</usr/sbin/postqueue -p>;
for (@data) {
if (/^(\w+)(\*|\!)?\s/) {
$queue_id = $1;
}
if($queue_id) {
if (/$REGEXP/i) {
$Q{$queue_id} = 1;
$queue_id = "";
}
}
}

#open(POSTSUPER,"|cat") || die "couldn't open postsuper" ;
open(POSTSUPER,"|postsuper -d -") || die "couldn't open postsuper" ;

foreach (keys %Q) {
print POSTSUPER "$_\n";
};
close(POSTSUPER);

For example, delete all queued messages from or to the domain called fackspamdomain.com, enter:

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





  Trả lời ngay kèm theo trích dẫn này
Gửi trả lời



Quyền Hạn Của Bạn
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is Mở
Hình Cảm xúc đang Mở
[IMG] đang Mở
Mã HTML đang Tắt




Bây giờ là 10:26 PM. Giờ GMT +7



Diễn đàn tin học QuantriNet
quantrinet.com | quantrimang.co.cc
Founded by Trương Văn Phương | Developed by QuantriNet's members.
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.