Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

net::server::mail(3pm) [debian man page]

Net::Server::Mail(3pm)					User Contributed Perl Documentation				    Net::Server::Mail(3pm)

NAME
Net::Server::Mail - Class to easily create a mail server SYNOPSIS
use Net::Server::Mail::SMTP; my @local_domains = qw(example.com example.org); my $server = new IO::Socket::INET Listen => 1, LocalPort => 25; my $conn; while($conn = $server->accept) { my $smtp = new Net::Server::Mail::SMTP socket => $conn; $smtp->set_callback(RCPT => &validate_recipient); $smtp->set_callback(DATA => &queue_message); $smtp->process(); $conn->close(); } sub validate_recipient { my($session, $recipient) = @_; my $domain; if($recipient =~ /@(.*)>s*$/) { $domain = $1; } if(not defined $domain) { return(0, 513, 'Syntax error.'); } elsif(not(grep $domain eq $_, @local_domains)) { return(0, 554, "$recipient: Recipient address rejected: Relay access denied"); } return(1); } sub queue_message { my($session, $data) = @_; my $sender = $session->get_sender(); my @recipients = $session->get_recipients(); return(0, 554, 'Error: no valid recipients') unless(@recipients); my $msgid = add_queue($sender, @recipients, $data); or return(0); return(1, 250, "message queued $msgid"); } DESCRIPTION
This module is a versatile and extensible implementation of the SMTP protocol and its different evolutions like ESMTP and LMTP. The event driven object-oriented API makes easy to incorporate the SMTP protocol to your programs. Other SMTPd implementations don't support useful ESMTP extensions and the LMTP protocol. Their interface design precludes adding them later. So I've decided to rewrite a complete implementation with extensibility in mind. It provides mechanism to easy addition future or not yet implemented ESMTP extensions. Developers can hook code at each SMTP session state and change the module's behaviors by registering event call-backs. The class is designed to be easily inherited from. This class is the base class for mail service protocols such axs Net::Server::Mail::SMTP, Net::Server::Mail::ESMTP and Net::Server::Mail::LMTP. Refer to the documentation provided with each of these modules. METHODS
new $instance = new Net::Server::Mail [option => 'value', ...] options: handle_in Sets the input handle, from which the server reads data. Defaults to STDIN. handle_out Sets the output handle, to which the server writes data. Defaults to STDOUT. socket Sets a socket to be used for server reads and writes instead of handles. error_sleep_time Number of seconds to wait for before printing an error message. This avoids some DoS attacks that attempt to flood the server with bogus commands. A value of 0 turns this feature off. Defaults to 0. idle_timeout Number of seconds a connection must remain idle before it is closed. A value of 0 turns this feature off. Defaults to 0. dojob Some command need to do some job after the handler call. Handler may want to overide this comportement to prevent from this job being executed. By calling this method with a (defined) false value as argument, expected job isn't executed. Defaults to true. set_callback ($success, $code, $msg) = $obj->set_callback(VERB, &function, $context)> Sets the callback code to be called on a particular event. The function should return 1 to 3 values: (success, [return_code, ["message"]]). $mailserver->set_callback ( 'RCPT', sub { my($address) = @_; if(is_relayed($address)) { # default success code/message will be used return 1; } else { return(0, 513, 'Relaying denied.'); } } ); process $mailserver->process; Start a new session. banner Send the introduction banner. You have to call it manually when are using process_once() method. Don't use it with process() method. EVENTS
banner Append at the opening of a new connection. Handler takes no argument. timeout This event append where timeout is exeded. Handler takes no argument. SEE ALSO
Please, see Net::Server::Mail::SMTP, Net::Server::Mail::ESMTP and Net::Server::Mail::LMTP. AUTHOR
Olivier Poitrey <rs@rhapsodyk.net> AVAILABILITY
Available on CPAN. anonymous SVN repository: svn co https://emailproject.perl.org/svn/Net-Server-Mail SVN repository on the web: http://emailproject.perl.org/svn/Net-Server-Mail/ BUGS
Please use CPAN system to report a bug (http://rt.cpan.org/). LICENCE
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA COPYRIGHT
Copyright (C) 2002 - Olivier Poitrey, 2007 - Xavier Guimard perl v5.10.0 2008-03-17 Net::Server::Mail(3pm)
Man Page