.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Net::Server::Mail::ESMTP::XFORWARD 3pm" .TH Net::Server::Mail::ESMTP::XFORWARD 3pm "2019-08-17" "perl v5.28.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Net::Server::Mail::ESMTP::XFORWARD \- A module to add support to the XFORWARD command in Net::Server::Mail::ESMTP .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Net::Server::Mail::ESMTP; \& \& my @local_domains = qw(example.com example.org); \& my $server = IO::Socket::INET\->new( Listen => 1, LocalPort => 25 ); \& \& my $conn; \& while($conn = $server\->accept) \& { \& my $esmtp = Net::Server::Mail::ESMTP\->new( socket => $conn ); \& \& # activate XFORWARD extension if remote client is localhost \& $esmtp\->register(\*(AqNet::Server::Mail::ESMTP::XFORWARD\*(Aq) \& if($server\->get_property(\*(Aqpeeraddr\*(Aq) =~ /^127/); \& # adding some handlers \& $esmtp\->set_callback(RCPT => \e&validate_recipient); \& # adding XFORWARD handler \& $esmtp\->set_callback(XFORWARD => \e&xforward); \& $esmtp\->process(); \& $conn\->close(); \& } \& \& sub xforward { \& my $self = shift; \& # Reject non IPV4 addresses \& return 0 unless( $self\->get_forwarded_address =~ /^\ed+\e.\ed+\e.\ed+\e.\ed+$/ ); \& 1; \& } \& \& sub validate_recipient \& { \& my($session, $recipient) = @_; \& my $domain; \& if($recipient =~ /\e@(.*)>\es*$/) \& { \& $domain = $1; \& } \& \& if(not defined $domain) \& { \& return(0, 513, \*(AqSyntax error.\*(Aq); \& } \& elsif(not(grep $domain eq $_, @local_domains) && $session\->get_forwarded_addr != "10.1.1.1") \& { \& return(0, 554, "$recipient: Recipient address rejected: Relay access denied"); \& } \& \& return(1); \& } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" When using a Net::Server::Mail::ESMTP script inside a \s-1MTA\s0 and not in front of Internet, values like client \s-1IP\s0 address are not accessible to the script and when the script returns mail to another instance of smtpd daemon, it logs \&\*(L"localhost\*(R" as incoming address. To solve this problem, some administrators use the \s-1XFORWARD\s0 command. This module gives the ability to read and store \s-1XFORWARD\s0 information. .SS "\s-1METHODS\s0" .IX Subsection "METHODS" These methods return the values set by the upstream \s-1MTA\s0 without modifying them so they can be set to undef or \*(L"[\s-1UNVAILABLE\s0]\*(R". See Postfix documentation for more. .IP "\(bu" 4 get_forwarded_values : returns a hash reference containing all values forwarded (keys in lower case). .IP "\(bu" 4 get_forwarded_name : returns the up-stream hostname. The hostname may be a non-DNS hostname. .IP "\(bu" 4 get_forwarded_address : returns the up-stream network address. Address information is not enclosed with []. The address may be a non-IP address. .IP "\(bu" 4 get_forwarded_source : returns \s-1LOCAL\s0 or \s-1REMOTE.\s0 .IP "\(bu" 4 get_forwarded_helo : returns the hostname that the up-stream host announced itself. It may be a non-DNS hostname. .IP "\(bu" 4 get_forwarded_proto : returns the mail protocol for receiving mail from the up-stream host. This may be an \s-1SMTP\s0 or non-SMTP protocol name of up to 64 characters. .SH "SEE ALSO" .IX Header "SEE ALSO" Net::Server::Mail::ESMTP, .SH "AUTHOR" .IX Header "AUTHOR" Xavier Guimard, .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright (C) 2006 by Xavier Guimard .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.6.4 or, at your option, any later version of Perl 5 you may have available.