2012-04-29 10:35:59 +02:00
|
|
|
#!perl -w
|
2014-09-18 07:22:17 +02:00
|
|
|
use strict;
|
2002-07-06 09:16:23 +02:00
|
|
|
|
2014-09-18 07:22:17 +02:00
|
|
|
use Qpsmtpd::Constants;
|
2002-09-08 15:23:38 +02:00
|
|
|
|
2014-09-18 07:22:17 +02:00
|
|
|
sub register {
|
|
|
|
my $self = shift;
|
|
|
|
$self->{_fortune} = '/usr/games/fortune';
|
|
|
|
return if ! $self->{_fortune};
|
2002-09-08 15:23:38 +02:00
|
|
|
|
2014-09-18 07:22:17 +02:00
|
|
|
# if fortune not installed, don't register hook
|
|
|
|
$self->register_hook('quit', 'fortune');
|
|
|
|
}
|
|
|
|
|
|
|
|
sub fortune {
|
|
|
|
my $self = shift;
|
|
|
|
my $qp = $self->qp;
|
|
|
|
|
|
|
|
# if she talks EHLO she is probably too sophisticated to enjoy the fun
|
|
|
|
return DECLINED if !$qp->connection->hello;
|
|
|
|
return DECLINED if $qp->connection->hello eq 'ehlo';
|
2002-11-06 07:42:55 +01:00
|
|
|
|
2014-09-18 07:22:17 +02:00
|
|
|
my @fortune = `$self->{_fortune} -s`;
|
2013-04-21 06:50:39 +02:00
|
|
|
@fortune = map { chop; s/^/ \/ /; $_ } @fortune;
|
|
|
|
$qp->respond(221, $qp->config('me') . " closing connection.", @fortune);
|
|
|
|
return DONE;
|
2002-07-06 09:16:23 +02:00
|
|
|
}
|