Apache-SMTP

 view release on metacpan or  search on metacpan

lib/Apache/SMTP/Server.pm  view on Meta::CPAN

    return($mailhost ? $mailhost : undef);
}

sub get_mailport {
    my $self = shift;
    my $mailport = $self->{mailport};
    return($mailport ? $mailport : 25);
}

#this is a copy of helo from Net::Server::Mail::SMTP with the minor change
#of setting $self->{hostname} so we can get it later
sub helo
{
    my($self, $hostname) = @_;

    unless(defined $hostname && length $hostname)
    {
        $self->reply(501, 'Syntax error in parameters or arguments');
        return;
    }
    $self->{hostname} = $hostname;
    $self->make_event
    (
        name => 'HELO',
        arguments => [$hostname],
        on_success => sub
        {
            # according to the RFC, HELO ensures "that both the SMTP client
            # and the SMTP server are in the initial state"
            $self->step_reverse_path(1);
            $self->step_forward_path(0);
            $self->step_maildata_path(0);
        },
        success_reply => [250, 'Requested mail action okay, completed'],
    );

    return;
}

1;
__END__

=head1 NAME

Apache::SMTP::Server - Subclass of Net::Server::Mail::SMTP with some additional
methods for getting remote ip and hostname and some config bits from Apache's
httpd.conf

=head1 SYNOPSIS

  use Apache::SMTP::Server;
  sub handler {
    my $c = shift;
    my $ath = Apache::TieBucketBrigade->new_tie($c);
                                                    
    my $smtp = Apache::SMTP::Server->new(         
        handle_in => $ath,
        handle_out => $ath,
    );
    $smtp->my_config($c);
    $smtp->set_callback(HELO => \&validate_hostname);
    $smtp->set_callback(RCPT => \&validate_recipient);
    $smtp->set_callback(DATA => \&queue_message);
    $smtp->set_callback(MAIL => \&validate_sender);
    $smtp->process;
    Apache::OK;
  }


=head1 DESCRIPTION

This module is used by Apache::SMTP to add some usefull functions to 
Net::Server::Mail::SMTP.  You probably don't need to subclass it yourself, but
you may want to if you need to add more configuration bits.  See Apache::SMTP
for example of use.

=head2 METHODS

=over 4

=item new ( handle_in => IO::Handle, handle_out => IO::Handle )

Takes an IO::Handle object for read and write, returns an 
Net::Server::Mail::SMTP object.

=item my_config ( Apache::Connection object )

Takes an Apache::Connection object and sets up some config variables.

=item get_local_ip

returns the ip bound in httpd.conf

=item get_hostname

returns hostname as given to HELO

=item get_remote_ip

returns ip of remote host

=item get_mailhost

returns hostname or ip used for outbound smtp connections from
PerlSetVar	MailHost	my.host.name
in httpd.conf

=item get_mailport

returns port to connect to for outbound smtp connections from
PerlSetVar	MailPort	25
in httpd.conf

=head1 SEE ALSO

Apache::SMTP
Net::Server::Mail
Net::Server::Mail::SMTP
Apache::TieBucketBrigade
Net::SMTP


=head1 AUTHOR



( run in 1.197 second using v1.01-cache-2.11-cpan-39bf76dae61 )