• Halloween is coming! To celebrate the occasion, we dusted off a couple of old skins, and even created a brand new one (Pixel).
    To get into the festive spirit, install the Skins extension.
  • The new Python extension is now available. It allows customers to deploy and manage WSGI-based Python applications on their websites directly from Plesk.
  • The Plesk Mobile apps for iOS and Android and the Plesk Mobile Center extension have been deprecated, and are no longer available for new installations. In Plesk Obsidian 18.0.84, the Plesk Mobile Center extension will be removed from servers during the upgrade, and the Plesk Mobile apps will lose their server management features.
  • The Social Login extension has been deprecated and will be removed in Plesk Obsidian 18.0.84. After that, it will no longer be possible to log in to Plesk with a Google, Facebook, GitHub account, or with a passkey. Plesk usernames and passwords, as well as logging in with a WebPros Account, are not affected.

Interesting email issue - In need of assistance

C

criticman

Guest
Alright, spammer got in, took care of that issue.

Failure notices galore in one inbox.

Attempting to login to webmail fails, and all IMAP and POP3 attempts timeout (we're talking nearly 200,000 messages in this box).

So, is there a command line way to delete messages containing "failure notice" in them? I know where the mailbox is in terms of the qmail mailname Maildir. I am just blanking on the command to locate messages with "failure notice" in them and automatically delete messages it matches.

I believe there are some important messages among the junk and need to be able to find them - so a complete deletion of the Maildir file contents using find -type f....etc will not be sufficient.

Thanks!
 
Below is a script that should do the job. You would execute it was follows:

./rm-maildir-messages.pl /var/qmail/mailnames/xyz.com/sales/Maildir "^Subject: failure notice$"

Code:
#!/usr/bin/perl

use strict;
use FileHandle;

my ($Maildir) = $ARGV[0] || die "Maildir not provided.\n";
my ($regexp) = qr/$ARGV[1]/;

MAIN:
{
   my ($subdir);

   unless (scalar @ARGV == 2)
   {
      die "$0 <maildir> <regexp>\n";
   }

   for $subdir ('cur', 'new')
   {
      clean_maildir ($Maildir . '/' . $subdir);
   }
};

sub clean_maildir
{
   my ($dirname) = @_;
   my ($dh) = new FileHandle();
   my ($file);

   opendir ($dh, $dirname) or die $!;

   while ($file = readdir ($dh))
   {
      next unless (-f $dirname . '/' . $file);

      my ($fh) = new FileHandle();
      next unless ($fh->open ($dirname . '/' . $file));

      while (<$fh>)
      {
         s/[\r\n]+$//;
         if ($_ =~ $regexp)
         {
#            printf "%s/%s\n", $dirname, $file;
            unlink ($dirname . '/' . $file);
         }
      }

      $fh->close();
   }

   closedir ($dh);
}
 
Back
Top