File Coverage

lib/POEST/Plugin/General.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             # $Id: General.pm,v 1.3 2003/04/08 00:27:30 cwest Exp $
2             package POEST::Plugin::General;
3              
4             =pod
5              
6             =head1 NAME
7              
8             POEST::Plugin::General - General SMTP commands implemented.
9              
10             =head1 ABSTRACT
11              
12             This class implements general SMTP commands, in order to get them
13             out of the way.
14              
15             =head1 DESCRIPTION
16              
17             There are some SMTP commands that are fairly straight forward
18             to implement, they are implemented here.
19              
20             =cut
21              
22 1     1   1278 use strict;
  1         2  
  1         47  
23             $^W = 1;
24              
25 1     1   5 use vars qw[$VERSION @ISA];
  1         2  
  1         70  
26             $VERSION = (qw$Revision: 1.3 $)[1];
27              
28 1     1   47 use POEST::Plugin;
  0            
  0            
29             @ISA = qw[POEST::Plugin];
30              
31             =head2 Events
32              
33             =head3 HELO
34              
35             Returns the response for C.
36              
37             =head3 ELOH
38              
39             Returns a simple "Ok" response to C.
40              
41             =head3 NOOP
42              
43             Returns the response for C.
44              
45             =head3 QUIT
46              
47             Returns the response for C.
48              
49             =head3 send_banner
50              
51             Sends the banner for the SMTP server when a session initializes. This
52             is how an SMTP server introduces itself to the client.
53              
54             =cut
55              
56             sub EVENTS () { [ qw[ HELO ELOH NOOP QUIT send_banner ] ] }
57              
58             =head2 Configuration
59              
60             =head3 hostname
61              
62             The hostname that we run as a primary. This is used when sending the
63             banner.
64              
65             =cut
66              
67             sub CONFIG () { [ qw[ hostname ] ] }
68              
69             sub send_banner {
70             my ($kernel, $self, $heap) = @_[KERNEL, OBJECT, HEAP];
71             my $client = $heap->{client};
72              
73             my $banner = "$self->{hostname} ESMTP poest/v0.1";
74              
75             $client->put( SMTP_SERVICE_READY, $banner );
76             }
77              
78             sub HELO {
79             my ($kernel, $self, $heap) = @_[KERNEL, OBJECT, HEAP];
80             my $client = $heap->{client};
81              
82             $client->put( SMTP_OK, qq[$self->{hostname} Ok] );
83             }
84              
85             sub ELOH {
86             my ($kernel, $self, $heap) = @_[KERNEL, OBJECT, HEAP];
87             my $client = $heap->{client};
88            
89             $client->put( SMTP_OK, qq[$self->{hostname} Ok] );
90             }
91              
92             sub NOOP {
93             my $client = $_[HEAP]->{client};
94              
95             $client->put( SMTP_OK, q[Ok] );
96             }
97              
98             sub QUIT {
99             my ($kernel, $heap) = @_[KERNEL, HEAP];
100             my $client = $heap->{client};
101              
102             $client->put( SMTP_QUIT, q[Bye!] );
103             $heap->{shutdown_now} = 1;
104             }
105              
106             1;
107              
108             __END__