#!/usr/bin/env perl use 5.20.0; use strict; use warnings; use Mail::Milter::Authentication::Pragmas; # ABSTRACT: A Perl Mail Authentication Milter client # PODNAME: authentication_milter_client our $VERSION = '2.20200625.2'; # VERSION use Email::Simple; use Getopt::Long; use Pod::Usage; use Mail::Milter::Authentication::Client; use Mail::Milter::Authentication::Config; # CONFIG my $help = 0; my $mailer_name = 'test.mta.example.com'; my $connect_ip = '127.0.0.1'; my $connect_name = 'localhost.localdomain'; my $connect_port = '54321'; my $connect_type = 'tcp4'; my $helo_host = 'localhost.example.com'; my $mail_from = 'test_user@localhost.example.com'; my $rcpt_to = 'test_user@mta.example.com'; my $mail_file = q{}; my $prefix; GetOptions ( 'mailer_name=s' => \$mailer_name, 'connect_ip=s' => \$connect_ip, 'connect_name=s' => \$connect_name, 'connect_port=s' => \$connect_port, 'connect_type=s' => \$connect_type, 'helo_host=s' => \$helo_host, 'mail_from=s' => \$mail_from, 'rcpt_to=s' => \$rcpt_to, 'mail_file=s' => \$mail_file, "help" => \$help, "prefix=s" => \$prefix, ) or die "Error in command line arguments\n"; if ( $help ) { usage(); exit 0; } if ( $prefix ) { $Mail::Milter::Authentication::Config::PREFIX = $prefix; } sub usage { pod2usage( -verbose => 2 ); } my $args = { 'mailer_name' => $mailer_name, 'connect_ip' => $connect_ip, 'connect_name' => $connect_name, 'connect_port' => $connect_port, 'connect_type' => $connect_type, 'helo_host' => $helo_host, 'mail_from' => $mail_from, 'rcpt_to' => $rcpt_to, }; die "Please supply a mail file" if ! $mail_file; if ( $mail_file eq '-' ) { my $mail_data = q{}; while ( my $l = <> ) { $mail_data .= $l; } $args->{'mail_data'} = $mail_data; } else { if ( ! -e $mail_file ) { die "Mail file $mail_file does not exist"; } $args->{'mail_file'} = $mail_file; } my $client = Mail::Milter::Authentication::Client->new( $args ); $client->process(); print $client->result(); __END__ =pod =encoding UTF-8 =head1 NAME authentication_milter_client - A Perl Mail Authentication Milter client =head1 VERSION version 2.20200625.2 =head1 USAGE authentication_milter_client [--mailer_name ] \ [--connect_ip ] [--connect_name ] [--connect_type ] \ [--helo_host ] [--mail_from ] [--rcpt_to ] \ [--mail_file ] \ [--prefix ] \ [-h|--help] =head1 OPTIONS =over =item -h|--help Show this help. =item --mail_file Filename of file containing the email contents. If the filename is set to - then the client will read from STDIN =item --prefix Read configuration from dir rather than /etc/ =item --mailer_name The name (fqdn) of the MTA =item --connect_ip The IP address of the host connecting to the mailer. =item --connect_name The name of the host connecting to the mailer. =item --connect_port The port of the connection to the mailer. =item --connect_type The type of connection to the mailer (eg tcp4). =item --helo_host The string passed in the HELO stage of the SMTP transaction. =item --mail_from
The string passed in the MAIL FROM stage of the SMTP transaction. =item --rcpt_to
The string passed in the RCPT TO stage of the SMTP transaction. =back =head1 AUTHOR Marc Bradshaw =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2020 by Marc Bradshaw. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut