The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Apache2::Protocol::ESMTP - Perl extension for

SYNOPSIS

  package My::Server;
  use base qw/Apache2::Protocol::ESMTP/;
  
  sub handler {
     my $c = shift;
     my $p = shift || My::Server->new;
     Apache2::Protocol::ESMTP::handler($c, $p);
  }

  sub CONNECT { ... };
  sub HELO { ... };
  sub EHLO { ... };
  .
  .
  .
  sub QUIT { ... };

DESCRIPTION

Apache2 ESMTP protocol base class. Out of the box this module can carry on and SMTP conversation. However, it's up to you to make it do anything interesting.

CONFIGURATION

Apache Configuration File

    LoadModule perl_module modules/mod_perl.so
    <VirtualHost myhost.com>
    ...
    PerlModule                   Apache2::Protocol::ESMTP 
    PerlProcessConnectionHandler Apache2::Protocol::ESMTP
    ...
    </VirtualHost>

METHODS

The following methods may be overridden by the subclass. All of the overridden methods except HEADER, EOH and BODY must return a proper status code and message, return($code, @msgs). For example return(250, 'Ok', 'Your command was successful).

CONNECT()

Gets called when a client connects to the server. By default the base class returns (220, 'ESMTP Mail Server').

UNKNOWN($command)

Gets called if the client sends a command that is not a part of the ESMTP protocol that we understand. By default the base class returns (500, "Command unrecognized: $line")

HELO($domain)

Gets called when the client sends the HELO command. $domain is the FQDN the client claims. By default the base class returns (250, 'OK').

EHLO($domain)

Gets called when the client sends the EHLO command. $domain is the FQDN the client claims. By default the base class returns (250, $self->client . ', pleased to meet you', 'HELP');

MAIL($env_sender)

Gets called when the client sends the MAIL command. $env_sender is the email address claimed by the sender of the message. By default the base class returns (250, $self->env_sender . ', sender ok');

RCPT($env_recipient)

Gets called when the client sends the RCPT command. $env_recipient is the email address the message is to be delivered to. By default the base class returns (250, $rcpt . ', recipient ok');

DATA()

Gets called when the client sends the DATA command. By default the base class returns (354, 'Enter mail, end with "." on a line by itself');

HEADER($name, $value)

Gets called for each message header. $name is the header name and $value is the header value. EOH is called when and line containing nothing except a <CR><LF> is sent or when a line is sent that does not conform to the specification for an ESMTP message header. No response is sent to the client.

EOH()

Gets called when and line containing nothing except a <CR><LF> is sent or when a line is sent that does not conform to the specification for an ESMTP message header. No response is sent to the client.

BODY($chunk)

Gets called for each chunk of data in the message body sent by the client. No response is sent to the client.

EOM()

Gets called when the client sends a line of the message body that contains nothing except '.<CR><LF>'. By default the base class returns (250, 'Message accepted for delivery');

EXPN($address)

Gets called when the client sends the EXPN command. By default the base class returns (502, 'Sorry we don\'t allow this operation');

VRFY($address)

Gets called when the client sends the VRFY command. By default the base class returns (252, 'Cannot VRFY user; try RCPT to attempt delivery');

NOOP()

Gets called when the client sends the NOOP command. By default the base class returns (250, 'OK');

RSET()

Gets called when the client sends the RSET command. By default the base class returns (250, 'OK');

HELP($command||undef)

Gets called when the client sends the HELP command. By default the base class returns (214, 'This is SMTP::Proxy 1.0');

QUIT()

Gets called when the client sends the QUIT command. By default the base class returns (221, 'Closing connection');

PROPERTIES

input_handle

Handle to read data from the client.

output_handle

Handle to write data to the client.

chunkmode

If set to true the next available data from the client will be read in chunks of size chunksize. If set to false data will be read a line at a time. The default behaviour is to start in line mode, switch to chunkmode after the message headers (EOH) and then switch back line mode after the message body (EOM).

chunksize

Sets the size of the chunks of data read from the client when chunkmode is set to true.

disconnect

When set to true, the sever will close the client connection when the current operation is complete. By default the client connection will be shutdown when the QUIT operation has completed.

SEE ALSO

Apache2::Protocol Apache2::ServerUtil

AUTHOR

Mike Smith <mike@mailchannels.com>

COPYRIGHT AND LICENSE

Copyright (C) 2005 by MailChannels Corporation. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.2 or, at your option, any later version of Perl 5 you may have available.