postfix_queue_management

Differenze

Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.

Link a questa pagina di confronto

postfix_queue_management [2020/06/12 19:27] (versione attuale)
admin creata
Linea 1: Linea 1:
 +Status/​Shape of Mail Queue
 +Postfix maintains different queues for different purpose.active ​ and  deferred queues are of our interest.
  
 +Ideally, we should never have a mail in deferred queue.
 +
 +qshape command will show shape of active mail queue by default. Ideally it should be as close as to empty since postfix sends email instantly!
 +<​code>​
 +qshape
 +</​code>​
 +Sample Outputs:
 +<​code>​
 +       ​T ​ 5 10 20 40 80 160 320 640 1280 1280+
 +TOTAL  0  0  0  0  0  0   ​0 ​  ​0 ​  ​0 ​   0     0
 +</​code>​
 +
 +If a mail is deferred, it will be moved to deferred queue.
 +
 +Running following command will show you the number of deferred emails for each domains…
 +<​code>​
 +qshape deferred
 +</​code>​
 +
 +Sample Output:
 +<​code>​
 +               ​T ​ 5 10 20 40 80 160 320 640 1280 1280+
 +        TOTAL  5  0  0  0  0  0   ​0 ​  ​0 ​  ​0 ​   0     5
 +    gmail.com ​ 4  0  0  0  0  0   ​0 ​  ​0 ​  ​0 ​   0     4
 +    yahoo.com ​ 1  0  0  0  0  0   ​0 ​  ​0 ​  ​0 ​   0     1
 +    ​
 +</​code>​
 +    ​
 +   
 +If you see mails to one or more domain only being deferred, check if you can connect to those servers from your network.
 +
 +Analyze mails in queue
 +
 +Dump entire mail queue
 +You can use either mailq or postqueue -pcommand. They will show an output like below:
 +<​code>​
 +
 +-Queue ID- --Size-- ----Arrival Time---- -Sender/​Recipient-------
 +2FC8824D24 ​   10588 Thu Sep 27 14:​52:​41 ​ from.me@example.com
 +(connect to alt2.gmail-smtp-in.l.google.com[74.125.79.26]:​25:​ Connection timed out)
 +                                         ​some.user@gmail.com
 +-- 16 Kbytes in 2 Requests.
 +You get dump for all emails from all mail queues including active & deferred queue.
 +
 +</​code>​
 +
 +Read an email from mail queue
 +Every message in queue has a unique id. You can read message in queue using a command like:
 +<​code>​
 +postcat -q  DA80E24A0A
 +</​code>​
 +
 +Or
 +<​code>​
 +postcat -qv  DA80E24A0A
 +</​code>​
 +
 +It will display your emails with headers and some more info. Using ‘v’ will display extra information.
 +
 +Attempt to send an email from mail queue
 +Its better to first open postfix log using something like below:
 +<​code>​
 +tail -f /​var/​log/​mail.{err,​log}
 +</​code>​
 +
 +Then you can identify a stuck mail and attempt to send it by using:
 +<​code>​
 +postqueue -i DA80E24A0A
 +</​code>​
 +
 +If that mail gets stuck again, check log tab to find reason.
 +
 +Once you fix issue, you can attempt to send that mail again. Mail ID inside queue remains same even if mail gets deferred again and again.
 +
 +Attempt to send all email from mail queue
 +Once you rectify issue and confident about delivery, you may try flushing entire queue immediately using:
 +<​code>​
 +postqueue -f
 +</​code>​
 +
 +Deleting Pending mails from queue
 +Sometimes you realize that all stuck emails are being sent to non-existent emails. Most likely emails generated because of some spam activity.
 +
 +Delete All Deferred Mails
 +In that case, you can simply delete all queued mails using:
 +<​code>​
 +postsuper -d ALL deferred
 +</​code>​
 +Delete a single mail from queue
 +If you want to just delete one mail, you can try:
 +<​code>​
 +postsuper -d DA80E24A0A
 +</​code>​
 +
 +Delete mails to a specific mail address
 +You need to some work here as postfix has no direct command for this.
 +
 +Following sample is taken from postsuper man page:
 +<​code>​
 +mailq | tail -n +2 | grep -v '^ *(' | awk  'BEGIN { RS = ""​ } { if ($8 == "​USER@EXAMPLE.COM"​ && $9 == ""​) print $1 } ' | tr -d '​*!'​ | postsuper -d -
 +</​code>​
 +
 +Just replace USER@EXAMPLE.COM with receiver email address.
 +
 +$8 will contain recipient1 email-address,​ $9 will contain recipient2 email-address.
 +
 +If you want to filter from-email address, use $7 variable.
  • postfix_queue_management.txt
  • Ultima modifica: 2020/06/12 19:27
  • da admin