2012-04-29 01:35:59 -07:00
|
|
|
#!perl -w
|
2014-09-17 22:22:17 -07:00
|
|
|
use strict;
|
2002-07-06 07:16:23 +00:00
|
|
|
|
2014-09-17 22:22:17 -07:00
|
|
|
use Qpsmtpd::Constants;
|
2002-09-08 13:23:38 +00:00
|
|
|
|
2014-09-17 22:22:17 -07:00
|
|
|
sub register {
|
|
|
|
my $self = shift;
|
|
|
|
$self->{_fortune} = '/usr/games/fortune';
|
2014-11-12 22:36:24 -08:00
|
|
|
return if ! -x $self->{_fortune};
|
2002-09-08 13:23:38 +00:00
|
|
|
|
2014-09-17 22:22:17 -07: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 06:42:55 +00:00
|
|
|
|
2014-09-17 22:22:17 -07:00
|
|
|
my @fortune = `$self->{_fortune} -s`;
|
2013-04-21 00:50:39 -04:00
|
|
|
@fortune = map { chop; s/^/ \/ /; $_ } @fortune;
|
|
|
|
$qp->respond(221, $qp->config('me') . " closing connection.", @fortune);
|
|
|
|
return DONE;
|
2002-07-06 07:16:23 +00:00
|
|
|
}
|