• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

qmail & greylisting spam control

Was looking to implement ASSP - but reading through this thread this maybe the better option.

One main query - is it possible to use a shared database on an external server rather than using localhost - looking at the initial config where it has allowed for MYSQLHOST to be defined this would seem to be possible.

Would this be a large performance hit?

and also is there any major changes needed to get this to run on a FreeBSD system.

Thanks
 
Actually one further query :

Is it possible to add whitelisted items on per domain basis by adding a MANUAL record that lists both an IP and a DOMAIN, this isnt clear on reading through this ticket or the patch code. I guess in theory this really shouldnt be an issue but would be nice so that we could allow users to whitelist their own items if they notice any issues.
 
results

I began the install myself but rather than mess up the system paid Brent's very reasonable install fee and had a professional install it. Excellent service.

Results today have seen spam reduced from my worst inbox at ~200/day down to ~10. Looking at the logs the spams that made it through are from a group of 4 IPs so with a little blacklist tweaking should see it reduced to heavenly levels.

I'm running GreyListing, MAPS, Spam and Assassin. Brent = hero :)

As a quick check, to BLACKLIST an IP I am presuming the SQL is ala -

Code:
INSERT INTO relaytofrom 
(relay_ip, mail_from, rcpt_to, block_expires, record_expires, origin_type, create_time) VALUES 
('213.171.216', NULL, NULL, '2099-12-31 23:59:59', NOW(), 'MANUAL', NOW());

or is the record_expires set to a distant date as well?

Cheers,
Graeme.
 
Nice working solution.

Still one question.

How to get work greylisting in combination with a fallbackmailserver?

Is a spammer send spam, mail1 reject, it comes to mail2 (they accep if greylisting is not setup).

If greylisting is also setup on mail2 they also reject.

Normal mail will be resend after x minutes. In a default situation mail will be delivered to mail1 en mail2? So all normal mail will be received two times?

Or im wrong?
 
Blacklist - Another question

As I have been doing quite a bit of work lately in the code for local_scan.c (which defines how the whitelist options work and what is being looked for in the database to determine if a message should be whitelisted) I note that in addition to whitelisting (an IP address as well as other options) the query that searches the database for the fields that you set for whitelisting can return both a white or a black result - if the result is white then the message is whitelisted but if the return is black then the message is blacklisted - these results override what the greylisting triplet scan would do with the message.

There's a number of posts on this forum that show how to construct a record in the database that will return the white result - but nothing on how to construct a database entry that would return a black result (thus blacklisting a mail server).

Anybody have any idea what such a database entry would look like?
 
Updated greylisting database cleanup script

Originally posted by bmeshier
I wanted to mention that you should run a nightly cron job to clean out old entries. Its not unusual for the table to grow over 1GB in size, especially if your the unlucky recipient of a joe-job or dictionary attack.

Create a quick perl script like this and place in /etc/cron.daily

Code:
#!/usr/bin/perl
use strict;
use warnings;

use constant DBD => 'DBI:mysql:qmail:localhost:3306';
use constant DBUSER => 'milter';
use constant DBPASS => 'greylist';

use DBI;

system ("cat /dev/null > /tmp/greylist_dbg.txt");

my $dbh = DBI->connect(DBD,DBUSER,DBPASS) or die "can't connect to db ", $DBI::errstr, ":$!";

$dbh->do("DELETE FROM relaytofrom WHERE record_expires < NOW() - INTERVAL 1 HOUR AND origin_type = 'AUTO'");
$dbh->do("OPTIMIZE TABLE relaytofrom");

$dbh->disconnect;

exit;


Updated greylisting database cleanup script


After using the amazing greylisting/qmail patch by Martin Dempsey [email protected] (& patched into plesk by Brent Meshier) I have been keeping an eye on the database that this generates.

If like me some of your users subscribe to mailing lists the size of the database can swell to a very great size indeed and typically 40-80% of the entries can be from mailing lists delivery attempts.
Normally this would still not be a problem but on a very busy system this could slow down the initial lookups quite considerably.

mailing lists programs like mailman use one-time-use email addresses when forwarding mails to subscribers. I'v personally seen this account for 75% of the entries in my local mailservers greylist database.

So Iv taken to cleaning the database out more regularly with some slightly stronger SQL;

This is the initial SQL for cleaning the database. Which is pretty good but

Code:
DELETE FROM relaytofrom WHERE record_expires < NOW() - INTERVAL 1 HOUR AND origin_type = 'AUTO'

I have also added two further queries which VASTLY, and to my mind quite safely, reduce the number of records in the database.

Code:
DELETE FROM relaytofrom WHERE passed_count = 0 AND last_update < NOW() - INTERVAL 1 DAY AND origin_type = 'AUTO'
DELETE FROM relaytofrom WHERE mail_from LIKE '%-return-%' AND blocked_count = 1 AND passed_count = 1 AND origin_type = 'AUTO' AND create_time < NOW() - INTERVAL 1 DAY


The first removed entries that have led to no successful deliveries and are more than one day old.
The second is aimed at the mailing lists and removed entries older than one day with -return- somewhere in the mail_from and passed_count & origin_type both at 1.




So here below is the amended greylist clean up script which includes all of the above mentioned cleanups
!!Remember to add your own login details!!

Code:
#!/usr/bin/perl
use strict;
use warnings;

use constant DBD => 'DBI:mysql:DATABASE_NAME:localhost:3306';
use constant DBUSER => 'DATABASE_USERNAME';
use constant DBPASS => 'DATABASE_PASSWORD';

use DBI;

system ("cat /dev/null > /tmp/greylist_dbg.txt");

my $dbh = DBI->connect(DBD,DBUSER,DBPASS) or die "can't connect to db ", $DBI::errstr, ":$!";

$dbh->do("DELETE FROM relaytofrom WHERE record_expires < NOW() - INTERVAL 1 HOUR AND origin_type = 'AUTO'");

# Clean out entries for mails that were not delivered with the last day
$dbh->do("DELETE FROM relaytofrom WHERE passed_count = 0 AND last_update < NOW() - INTERVAL 1 DAY AND origin_type = 'AUTO'");

# Clean out entries from mailing lists older then 1 day.
# They typically have -return- somewhere in their from address and only get delivered once ever (hence the blocked_count & passed_count both at 1 )
# PLEASE CHECK THIS IS SUITABLE FOR YOUR SYSTEM BEFORE IMPLEMENTING
# -----------------------------------------------------------------
$dbh->do("DELETE FROM relaytofrom WHERE mail_from LIKE '%-return-%' AND blocked_count = 1 AND passed_count = 1 AND origin_type = 'AUTO' AND create_time < NOW() - INTERVAL 1 DAY");

$dbh->do("OPTIMIZE TABLE relaytofrom");

$dbh->disconnect;

exit;


Comments and other suggestions are always welcome
 
Hi there,

has somebody greylisting running on Plesk 8.1 with Debian 3.1 stable ?

compiling brings the following error:

chmod 755 binm3+df
./compile spfquery.c
spfquery.c: In function `main':
spfquery.c:24: warning: return type of `main' is not `int'
./load spfquery spf.o ip.o ipme.o ipalloc.o strsalloc.o \
now.o dns.o datetime.a stralloc.a alloc.a str.a substdio.a \
case.a error.a fs.a `cat dns.lib` `cat socket.lib`
 
Yes, and it works well.

I had only to recompile from my patched source after upgrade from 8.0 to 8.1 on debian 3.1
since the upgrader overwrite the previous qmail files (a swsoft technicien said to me there was no diffs in qmail patches between versions 8.0 and 8.1)
 
Hi Claus,

it works.....thank you for your help. Now i have an other little problem with the perl script. The following error comes up when i try to start it:

syntax error at /etc/cron.daily/greylist.pl line 16, near "(."
Execution of /etc/cron.daily/greylist.pl aborted due to compilation errors.

any idea :)
 
To Specimen > i'm using the same debian / plesk 8 than you.

How did you installed it? Is it OK now?
 
Hello again,

@romino
yes, it works fine now :) I have made only a few changes:

1.)Instead of mysql-devel, you must install libmysqlclient10-dev

2.)In the Makefile from qmail, you must change the path to libmysqlclient.a to /usr/lib/libmysqlclient.a (2 x )

3.)Instead of stopping qmail with
/etc/rc.d/init.d/qmail stop

you must type

/etc/init.d/qmail stop

All other points are the same as in the howto from bmeshier in the first post of this thread.

specimen
 
ok, thanks. I will try it this afternoon
Just one questiton:
you say:
2.)In the Makefile from qmail, you must change the path to libmysqlclient.a to /usr/lib/libmysqlclient.a (2 x )
What do you mean? which file? Could you tell me a little bit more, because i dont see any step relating this in howto
 
Hi again,

when you have decompressed qmail-1.03-psa-greylist.tar.gz and changed to that directory, there is a file named "Makefile". Open it with vi or ee or whatever editor you like an search for the path to libmysqlclient.a Correct the path ans save the file.

Now you can run "make" without the error "libmysqlclient.a not found"


regards

specimen
 
ok! great! thanks a lot!

last thing: in which directory did you untar it? What is the best choice?
 
well, that was the one i was thinling about LOL :D

Thanks a lot and have a nice day
 
Nice working solution.

Still one question.

How to get greylisting work in combination with a fallbackmailserver?

Is a spammer send spam, mail1 reject, it comes to mail2 (they accep if greylisting is not setup).

If greylisting is also setup on mail2 they also reject.

Normal mail will be resend after x minutes. In a default situation mail will be delivered to mail1 en mail2? So all normal mail will be received two times?

Or im wrong?
 
Hi,

I've installed greylist on my plesk 8 server. Unfortunately some clients dont want to understand the 1 hour delay before a message 'arrives'... I put their domain in rcpt_to whitelist...

Though it seems to me that the relay_ip = senderrelayip rule is too restrictive for legitimate emails (I mean messages that already passed once).
For some reason, SMTP relay can be different for a unique sender (so its IP). For each relay IP, greylist creates a new block. And the email is one more time delayed (whereas previous messages passed) - also making the RECORD_EXPIRE_GOOD period useless.

The less legitimate emails are delayed, the best it is...

So do you think passing emails only when rcpt_to like '%recieverdomain.com' and mail_from = '[email protected]' (and not null) make sense ?

Thanx !
 
Hello,
can somebody help me ??

i get this error:

make
( cat warn-auto.sh; \
echo CC=\'`head -1 conf-cc`\'; \
echo LD=\'`head -1 conf-ld`\' \
) > auto-ccld.sh
cat auto-ccld.sh make-load.sh > make-load
chmod 755 make-load
cat auto-ccld.sh find-systype.sh > find-systype
chmod 755 find-systype
./find-systype > systype
( cat warn-auto.sh; ./make-load "`cat systype`" ) > load
chmod 755 load
cat auto-ccld.sh make-compile.sh > make-compile
chmod 755 make-compile
( cat warn-auto.sh; ./make-compile "`cat systype`" ) > \
compile
chmod 755 compile
( ( ./compile tryvfork.c && ./load tryvfork ) >/dev/null \
2>&1 \
&& cat fork.h2 || cat fork.h1 ) > fork.h
rm -f tryvfork.o tryvfork
./compile qmail-local.c
qmail-local.c: In Funktion »main«:
qmail-local.c:760: Warnung: Rückgabetyp von »main« ist nicht »int«
./compile qsutil.c
./compile qmail.c
./compile quote.c
./compile now.c
./compile gfrom.c
./compile myctime.c
./compile slurpclose.c
cat auto-ccld.sh make-makelib.sh > make-makelib
chmod 755 make-makelib
( cat warn-auto.sh; ./make-makelib "`cat systype`" ) > \
makelib
chmod 755 makelib
./compile case_diffb.c
./compile case_diffs.c
./compile case_lowerb.c
./compile case_lowers.c
./compile case_starts.c
./makelib case.a case_diffb.o case_diffs.o case_lowerb.o \
case_lowers.o case_starts.o
./compile getln.c
./compile getln2.c
./makelib getln.a getln.o getln2.o
./compile subgetopt.c
./compile sgetopt.c
./makelib getopt.a subgetopt.o sgetopt.o
./compile sig_alarm.c
( ( ./compile trysgprm.c && ./load trysgprm ) >/dev/null \
2>&1 \
&& echo \#define HASSIGPROCMASK 1 || exit 0 ) > hassgprm.h
rm -f trysgprm.o trysgprm
./compile sig_block.c
( ( ./compile trysgact.c && ./load trysgact ) >/dev/null \
2>&1 \
&& echo \#define HASSIGACTION 1 || exit 0 ) > hassgact.h
rm -f trysgact.o trysgact
./compile sig_catch.c
./compile sig_pause.c
./compile sig_pipe.c
./compile sig_child.c
./compile sig_hup.c
./compile sig_term.c
./compile sig_bug.c
./compile sig_misc.c
./makelib sig.a sig_alarm.o sig_block.o sig_catch.o \
sig_pause.o sig_pipe.o sig_child.o sig_hup.o sig_term.o \
sig_bug.o sig_misc.o
./compile open_append.c
./compile open_excl.c
./compile open_read.c
./compile open_trunc.c
./compile open_write.c
./makelib open.a open_append.o open_excl.o open_read.o \
open_trunc.o open_write.o
./compile seek_cur.c
./compile seek_end.c
./compile seek_set.c
./compile seek_trunc.c
./makelib seek.a seek_cur.o seek_end.o seek_set.o \
seek_trunc.o
( ( ./compile tryflock.c && ./load tryflock ) >/dev/null \
2>&1 \
&& echo \#define HASFLOCK 1 || exit 0 ) > hasflock.h
rm -f tryflock.o tryflock
./compile lock_ex.c
./compile lock_exnb.c
./compile lock_un.c
./makelib lock.a lock_ex.o lock_exnb.o lock_un.o
./compile fd_copy.c
./compile fd_move.c
./makelib fd.a fd_copy.o fd_move.o
( ( ./compile trywaitp.c && ./load trywaitp ) >/dev/null \
2>&1 \
&& echo \#define HASWAITPID 1 || exit 0 ) > haswaitp.h
rm -f trywaitp.o trywaitp
./compile wait_pid.c
./compile wait_nohang.c
./makelib wait.a wait_pid.o wait_nohang.o
./compile env.c
./compile envread.c
./makelib env.a env.o envread.o
./compile stralloc_eady.c
./compile stralloc_pend.c
./compile stralloc_copy.c
./compile stralloc_opys.c
./compile stralloc_opyb.c
./compile stralloc_cat.c
./compile stralloc_cats.c
./compile stralloc_catb.c
./compile stralloc_arts.c
./makelib stralloc.a stralloc_eady.o stralloc_pend.o \
stralloc_copy.o stralloc_opys.o stralloc_opyb.o \
stralloc_cat.o stralloc_cats.o stralloc_catb.o \
stralloc_arts.o
./compile alloc.c
./compile alloc_re.c
./makelib alloc.a alloc.o alloc_re.o
./compile strerr_sys.c
./compile strerr_die.c
./makelib strerr.a strerr_sys.o strerr_die.o
./compile substdio.c
./compile substdi.c
./compile substdo.c
./compile subfderr.c
./compile subfdout.c
./compile subfdouts.c
./compile subfdin.c
./compile subfdins.c
./compile substdio_copy.c
./makelib substdio.a substdio.o substdi.o substdo.o \
subfderr.o subfdout.o subfdouts.o subfdin.o subfdins.o \
substdio_copy.o
./compile error.c
./compile error_str.c
./compile error_temp.c
./makelib error.a error.o error_str.o error_temp.o
./compile str_len.c
./compile str_diff.c
./compile str_diffn.c
./compile str_cpy.c
./compile str_cpyb.c
./compile str_chr.c
./compile str_rchr.c
./compile str_start.c
./compile byte_chr.c
./compile byte_rchr.c
./compile byte_cspn.c
./compile byte_rcspn.c
./compile byte_diff.c
./compile byte_copy.c
./compile byte_cr.c
./compile byte_zero.c
./makelib str.a str_len.o str_diff.o str_diffn.o str_cpy.o str_cpyb.o \
str_chr.o str_rchr.o str_start.o byte_chr.o byte_rchr.o byte_cspn.o \
byte_rcspn.o byte_diff.o byte_copy.o byte_cr.o byte_zero.o
./compile fmt_str.c
./compile fmt_strn.c
./compile fmt_uint.c
./compile fmt_uint0.c
./compile fmt_ulong.c
./compile scan_ulong.c
./compile scan_8long.c
./makelib fs.a fmt_str.o fmt_strn.o fmt_uint.o fmt_uint0.o \
fmt_ulong.o scan_ulong.o scan_8long.o
./compile datetime.c
./compile datetime_un.c
./makelib datetime.a datetime.o datetime_un.o
./compile auto-str.c
auto-str.c:9: Warnung: conflicting types for built-in function `puts'
auto-str.c: In Funktion »main«:
auto-str.c:17: Warnung: Rückgabetyp von »main« ist nicht »int«
./load auto-str substdio.a error.a str.a
/usr/bin/ld: cannot find -lssl
collect2: ld returned 1 exit status
make: *** [auto-str] Fehler 1

i have debian...

thx
 
Back
Top