Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section Web Server
  • Search

[HowTo] Flush/Clear/Delete Postfix Mail Queue for VestaCP

Questions regarding the Web Server
Apache + Nginx, Nginx + PHP5-FPM
Post Reply
  • Print view
Advanced search
1 post • Page 1 of 1
xorro
Posts: 87
Joined: Sun Nov 13, 2016 3:11 pm
Contact:
Contact xorro
Website Skype

Os: CentOS 6x
Web: apache + nginx
[HowTo] Flush/Clear/Delete Postfix Mail Queue for VestaCP
  • Quote

Post by xorro » Tue Sep 11, 2018 6:53 pm

This is short tutorial for clearing the mail queue from command line. Postfix is the mail server which is used to send mails, time to time there will increase in mail queue which contains failed email in order to check and clear the mail queue just run this following command from terminal/ssh.

To check mail queue:

Code: Select all

mailq
To remove all mail from the queue:

Code: Select all

postsuper -d ALL
To remove all mails in the deferred queue:

Code: Select all

postsuper -d ALL deferred
Also you can use this script to delete mail queue which contain certain keyword or email id :

Code: Select all

cd /root
touch mailq-del.pl
chmod 775 mailq-del.pl
nano mailq-del.pl
and add this below code in mailq-del.pl and save it :

Code: Select all

#!/usr/bin/perl
 
$REGEXP = shift || die "no email-adress given (regexp-style, e.g. bl.*\@gmail.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);
example usage of script :

Code: Select all

cd /root
./mailq-del.pl [email protected]
or
./mailq-del.pl keyword
Top


Post Reply
  • Print view
1 post • Page 1 of 1

Return to “Web Server”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password