Apache-SMTP
view release on metacpan or search on metacpan
lib/Apache/SMTP.pm view on Meta::CPAN
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;
}
sub validate_hostname {
my ($session, $hostname) = @_;
return(1, 250, "ok");
}
sub validate_recipient {
my ($session, $recipient) = @_;
return(1, 250, "ok");
}
sub validate_sender {
my ($session, $sender) = @_;
return(1, 250, "ok");
}
sub queue_message {
my($session, $data) = @_;
my $sender = $session->get_sender();
my @recipients = $session->get_recipients();
my $mailhost = $session->get_mailhost();
my $mailport = $session->get_mailport();
lib/Apache/SMTP.pm view on Meta::CPAN
This implements a very simple SMTP server using Apache and mod_perl 2. The
current behavior is to immediately send (using Net::SMTP) any mail it
receives to the server set using
PerlSetVar MailHost
on
port PerlSetVar MailPort
Because of the above behavior, this module _may_ act as an ***OPEN RELAY***
which is a bad thing. So please do not configure it as such. Instead,
subclass this module and write your own validate_sender() and
validate_recipient() methods. Alternatively, do not have your mail server
allow relaying from this server's ip, and you should be ok.
Also, this module, despite the methods "add_queue" and "queue_message" does
not actually implement a queue in the normal MTA sense of the word. Maybe
you would like to implement one?
=head2 SUBCLASS
=over 4
You may want to subclass this module and write your own version of the
following
=item validate_hostname
sub validate_hostname {
my ($session, $hostname) = @_;
return(1, 250, "ok");
}
=item validate_sender
sub validate_sender {
my ($session, $sender) = @_;
return(1, 250, "ok");
}
=item validate_recipient
sub validate_recipient {
my ($session, $recipient) = @_;
return(1, 250, "ok");
}
=item queue_message
sub queue_message {
my($session, $data) = @_;
my $msgid = add_queue({mailhost => 'hostname',
mailport => '25',
lib/Apache/SMTP/Server.pm view on Meta::CPAN
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
( run in 0.506 second using v1.01-cache-2.11-cpan-4d50c553e7e )