Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
AUTH(3)		      User Contributed Perl Documentation	       AUTH(3)

NAME
       Net::Server::Mail::ESMTP::AUTH -	SMTP Authentification extensions for
       Net::Server::Mail::ESMTP

SYNOPSIS
	 use Net::Server::Mail::ESMTP;
	 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 $esmtp = new Net::Server::Mail::ESMTP socket => $conn;

	   # activate AUTH extension
	   $esmtp->register('Net::Server::Mail::ESMTP::AUTH');

	   # adding AUTH handler
	   $esmtp->set_callback(AUTH =>	\&validate_auth);
	   $esmtp->set_callback(DATA =>	\&queue_message);
	   $esmtp->process;
	 }

	 sub validate_auth
	 {
	   my ($session, $username, $password) = @_;

	   if ($username eq 'ROBERT' and $password eq 'TOTO04')	{
	     # AUTH SUCCESFULL
	     $session->{AUTH}->{ok} = 1;
	     return 1;
	   } else {
	     # AUTH FAILED
	     return 0;
	   }
	 }

       sub queue_message {
	   my($session,	$data) = @_;

	   # providing AUTH doesn't make it mandatory.
	   # A client might not	use AUTH at all!
	   # You must deal now with permissions:

	   unless ($session->{AUTH}->{ok}) {
	       # warn "no AUTH supplied!";
	       return(0, 530, 'Error: Authentication required');
	   }
	   ... do stuff
       }

FEATURES
	 * AUTH	LOGIN method support
	 * AUTH	PLAIN method support

DESCRIPTION
       "Net::Server::Mail::ESMTP::AUTH"	is an extension	to provide ESMTP
       Authentification	support	to Net::Server::Mail::ESMTP module.  Actually
       only AUTH LOGIN and AUTH	PLAIN methods are supported.

       AUTH callback is	called with login and password who was given by	user's
       mail client, AUTH callback should return	1 when authentification
       mechanism was succesfull	otherwise 0.

SEE ALSO
       Please, see Net::Server::Mail::SMTP and Net::Server::Mail::ESMTP	for
       more documentations.

AUTHOR
       Sylvain Cresto <scresto@gmail.com>

       Thanks to Chris <chris at u- club.de>

BUGS
       Please send bug-reports to scresto@gmail.com.

LICENCE
       This library is free software; you can redistribute it and/or modify it
       under the same terms as Perl itself.

COPYRIGHT
       Copyright (C) 2004, 2016	- Sylvain Cresto

perl v5.32.0			  2016-10-14			       AUTH(3)

NAME | SYNOPSIS | FEATURES | DESCRIPTION | SEE ALSO | AUTHOR | BUGS | LICENCE | COPYRIGHT

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=Net::Server::Mail::ESMTP::AUTH&sektion=3&manpath=FreeBSD+12.2-RELEASE+and+Ports>

home | help