qpsmtpd/plugins/quit_fortune
2014-09-17 22:22:44 -07:00

28 lines
701 B
Perl

#!perl -w
use strict;
use Qpsmtpd::Constants;
sub register {
my $self = shift;
$self->{_fortune} = '/usr/games/fortune';
return if ! $self->{_fortune};
# 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';
my @fortune = `$self->{_fortune} -s`;
@fortune = map { chop; s/^/ \/ /; $_ } @fortune;
$qp->respond(221, $qp->config('me') . " closing connection.", @fortune);
return DONE;
}