Author Topic: To many spams - Postfix Mail Queue  (Read 637 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
To many spams - Postfix Mail Queue
« on: April 18, 2018, 07:09:35 PM »

On my email account has received more than 32 000 spams( in 12h )

When I have tried to delete those spams on page ( CWP Admin > Email > Manage Mail Queue )

I have got a error message:

Code: [Select]
Fatal error

:  Maximum execution time of 90 seconds exceeded in /usr/local/cwpsrv/htdocs/resources/admin/modules/mail_queue.php  on line 0

I stopped Postfix Mail Server, but next day it's activate again by itself, and now I have more than 53 900 spams for one email account.

I have tried to set new password, but it is not helped.

How to remove those spams?

Thanks

Offline
*
Re: To many spams - Postfix Mail Queue
« Reply #1 on: April 18, 2018, 10:40:21 PM »
#1 - You should change the configuration of your mail server so that the spam filters are enabled. This is to block further receipt of spam mails.

CPanel > Email > MailServer Manager > enable AntiSpam/AntiVirus + rDNS Check if not already enabled > Rebuild mail server.

#2 - To clean up a massive amount of e-mails in the postfix queue, the web interface is not going to work. You'll need to connect to the server using a SSH client, log in with a standard account, SU to get root, then create a PERL script file using the code below and run it with the source or destination e-mail address as parameter:

Code: [Select]
#!/usr/bin/perl -w
#
# pfdel - deletes message containing specified address from
# Postfix queue. Matches either sender or recipient address.
#
# Usage: pfdel <email_address>
#

use strict;

# Change these paths if necessary.
my $LISTQ = "/usr/sbin/postqueue -p";
my $POSTSUPER = "/usr/sbin/postsuper";

my $email_addr = "";
my $qid = "";
my $euid = $>;

if ( @ARGV !=  1 ) {
die "Usage: pfdel <email_address>\n";
} else {
$email_addr = $ARGV[0];
}

if ( $euid != 0 ) {
        die "You must be root to delete queue files.\n";
}


open(QUEUE, "$LISTQ |") ||
  die "Can't get pipe to $LISTQ: $!\n";

my $entry = <QUEUE>; # skip single header line
$/ = ""; # Rest of queue entries print on
# multiple lines.
while ( $entry = <QUEUE> ) {
if ( $entry =~ / $email_addr$/m ) {
($qid) = split(/\s+/, $entry, 2);
$qid =~ s/[\*\!]//;
next unless ($qid);

#
# Execute postsuper -d with the queue id.
# postsuper provides feedback when it deletes
# messages. Let its output go through.
#
if ( system($POSTSUPER, "-d", $qid) != 0 ) {
# If postsuper has a problem, bail.
die "Error executing $POSTSUPER: error " .
   "code " .  ($?/256) . "\n";
}
}
}
close(QUEUE);

if (! $qid ) {
die "No messages with the address <$email_addr> " .
  "found in queue.\n";
}

exit 0;

Save this somewhere (/root would be fine) as pfdel.pl, make it executable with chmod, then run it with keywords like:

./pfdel.pl somedomain.tld

This would process the entire mail queue and delete all mails with the specified text in the e-mail address of sender or receiver.
« Last Edit: April 18, 2018, 10:44:05 PM by puterfixer »

Offline
*
Re: To many spams - Postfix Mail Queue
« Reply #2 on: April 19, 2018, 07:49:56 PM »
I have already had AntiSpam/AntiVirus enabled on my mail server.

How to clean up all e-mails in the postfix queue? Do you know Command lines for that?

Actually I want to clean all mails on my server...

Thanks

Offline
*
Re: To many spams - Postfix Mail Queue
« Reply #3 on: April 22, 2018, 06:37:41 AM »
I disabled send mail and setup server cron.
Code: [Select]
*/5 * * * * /usr/sbin/postsuper -d ALL

Offline
*
Re: To many spams - Postfix Mail Queue
« Reply #4 on: April 23, 2018, 12:05:25 PM »
before deleting any emails you should check from where they come as it can be internal hacked php script

here are the postfix commands to clean your mail queue
http://wiki.centos-webpanel.com/postfix-mail-server-commands
VPS & Dedicated server provider with included FREE Managed support for CWP.
http://www.studio4host.com/

*** Don't allow that your server or website is down, choose hosting provider with included expert managed support for your CWP.

Offline
*
Re: To many spams - Postfix Mail Queue
« Reply #5 on: May 02, 2018, 12:42:02 AM »
Thank You