Mail-Sender
view release on metacpan or search on metacpan
- Reorganized the PM files into the lib directory
- Auto-generate MANIFEST using MANIFEST.SKIP from here on
- Ensure all files EOL with \n rather than any combination of \n and \r\n
- Renamed many undocumented/private functions to names beginning with _
- Added many, many tests for coverage and to prevent regressions
- Updated Config.PL to modernize.
- Lazily load Win32API::Registry for ::CType::Win32
0.8.23 2014-07-15
- fixed problems with long subjects containing accentuated characters
- fixed problems with IO::Socket::SSL
- trims addresses passed in an array (per request)
- changed licence per request from Fedora
- fix to allow very long passwords
- fix error in TestServer()
0.8.22 2012-12-12
- minor fixes
0.8.21 2012-05-27
- fixed the case in the header names (Content-type -> Content-Type)
"Test::Pod::Coverage" : "1.08",
"Test::Pod::Spelling::CommonMistakes" : "1.000",
"Test::Spelling" : "0.12",
"Test::Version" : "1"
}
},
"runtime" : {
"recommends" : {
"Authen::NTLM" : "0",
"Digest::HMAC_MD5" : "0",
"IO::Socket::SSL" : "0",
"Mozilla::CA" : "0",
"Net::SSLeay" : "0"
},
"requires" : {
"Carp" : "0",
"Encode" : "0",
"Exporter" : "0",
"File::Basename" : "0",
"IO::Handle" : "0",
"IO::Socket::INET" : "0",
version: '0.903'
Mail::Sender::DBIO:
file: lib/Mail/Sender.pm
version: '0.903'
Mail::Sender::IO:
file: lib/Mail/Sender.pm
version: '0.903'
recommends:
Authen::NTLM: '0'
Digest::HMAC_MD5: '0'
IO::Socket::SSL: '0'
Mozilla::CA: '0'
Net::SSLeay: '0'
requires:
Carp: '0'
Encode: '0'
Exporter: '0'
File::Basename: '0'
IO::Handle: '0'
IO::Socket::INET: '0'
MIME::Base64: '0'
You may add support for other authentication protocols yourself.
auth_encoded
# mutating single attributes could get costly!
$sender = $sender->new({auth_encoded => 1});
my $auth_enc = $sender->{auth_encoded}; # reach in to grab
If set to a true value, Mail::Sender attempts to use TLS (encrypted
connection) whenever the server supports it and you have
IO::Socket::SSL and Net::SSLeay.
The default value of this option is true! This means that if
Mail::Sender can send the data encrypted, it will.
authdomain
# mutating single attributes could get costly!
$sender = $sender->new({authdomain => 'bar.com'});
my $domain = $sender->{authdomain}; # reach in to grab
# -14 = connection not established. Did you mean MailFile instead of SendFile?
# -15 = no SMTP server specified
# -16 = no From: address specified
# -17 = authentication protocol not accepted by the server
# -18 = login not accepted
# -19 = authentication protocol is not implemented
# -20 = all recipients were rejected by the server
# -21 = file specified as an attachment cannot be read
# -22 = failed to open the specified debug file for writing
# -23 = STARTTLS failed (for SSL or TLS encrypted connections)
# -24 = IO::Socket::SSL->start_SSL failed
# -25 = TLS required by the specified options, but the required modules are not available. Need IO::Socket::SSL and Net::SSLeay
# -26 = TLS required by the specified options, but the server doesn't support it
# -27 = unknown encoding specified for the mail body, part or attachment. Only base64, quoted-printable, 7bit and 8bit supported.
my $on_errors = $sender->{on_errors}; # reach in to grab
say $Mail::Sender::Error; # contains a textual description of last error.
This option allows you to affect the way Mail::Sender reports errors.
All methods return the $sender object if they succeed.
$Mail::Sender::Error $sender->{'error'} and $sender->{'error_msg'} are
set in all cases.
# mutating single attributes could get costly!
$sender = $sender->new({smtp => 'smtp.bar.com'});
my $smtp = $sender->{smtp}; # reach in to grab
The IP address or domain of your SMTP server.
ssl_...
The ssl_version, ssl_verify_mode, ssl_ca_path, ssl_ca_file,
ssl_verifycb_name, ssl_verifycn_schema and ssl_hostname options (if
specified) are passed to "start_SSL" in IO::Socket::SSL. The default
version is TLSv1 and verify mode is IO::Socket::SSL::SSL_VERIFY_NONE.
If you change the ssl_verify_mode to SSL_VERIFY_PEER, you may need to
specify the ssl_ca_file. If you have Mozilla::CA installed, then
setting it to Mozilla::CA::SSL_ca_file() may help.
subject
# mutating single attributes could get costly!
$sender = $sender->new({subject => 'An email is coming!'});
my $subject = $sender->{subject}; # reach in to grab
tls_allowed
# mutating single attributes could get costly!
$sender = $sender->new({tls_allowed => 1}); # true, default
$sender = $sender->new({tls_allowed => 0}); # false
my $tls = $sender->{tls_allowed}; # reach in to grab
If set to a true value, Mail::Sender will attempt to use TLS (encrypted
connection) whenever the server supports it. This requires that you
have IO::Socket::SSL and Net::SSLeay.
tls_required
# mutating single attributes could get costly!
$sender = $sender->new({tls_required => 1}); # true, require TLS encryption
$sender = $sender->new({tls_required => 0}); # false, plain. default
my $required = $sender->{tls_required};
If you set this option to a true value, the module will fail if it's
unable to use TLS.
requires 'MIME::Base64';
requires 'MIME::QuotedPrint';
requires 'Socket';
requires 'Symbol';
requires 'Tie::Handle';
requires 'Time::Local';
requires 'Win32API::Registry' if $^O eq 'MSWin32';
recommends 'Authen::NTLM';
recommends 'Digest::HMAC_MD5';
recommends 'IO::Socket::SSL';
recommends 'Mozilla::CA';
recommends 'Net::SSLeay';
};
on 'test' => sub {
requires 'Test::More' => '0.88';
};
on 'develop' => sub {
requires 'Test::CheckManifest' => '1.29';
lib/Mail/Sender.pm view on Meta::CPAN
);
# if you do not use MailFile or SendFile and only send 7BIT or 8BIT "encoded"
# messages you may comment out these lines.
#MIME::Base64 and MIME::QuotedPrint may be found at CPAN.
my $TLS_notsupported;
BEGIN {
eval <<'END'
use IO::Socket::SSL;# qw(debug4);
use Net::SSLeay;
1;
END
or $TLS_notsupported = $@;
}
# include config file and libraries when packaging the script
if (0) {
require 'Mail/Sender.config'; # local configuration
require 'Symbol.pm'; # for debuging and GetHandle() method
lib/Mail/Sender.pm view on Meta::CPAN
my $msg = shift || '';
my $two = shift || '';
$! = 5;
$Error = "STARTTLS failed: $msg $two";
return -23, $Error;
}
sub _IO_SOCKET_SSL {
my $msg = shift || '';
$! = 5;
$Error = "IO::Socket::SSL->start_SSL failed: $msg";
return -24, $Error;
}
sub _TLS_UNSUPPORTED_BY_ME {
my $msg = shift || '';
$! = 5;
$Error = "TLS unsupported by the script: $msg";
return -25, $Error;
}
lib/Mail/Sender.pm view on Meta::CPAN
$Net::SSLeay::random_device = $0 if (!-s $Net::SSLeay::random_device);
Net::SSLeay::randomize();
my $res = send_cmd $s, "STARTTLS";
my ($code, $text) = split(/\s/, $res, 2);
return $self->Error(_STARTTLS($code, $text)) if ($code != 220);
my %ssl_options = (
SSL_version => 'TLSv1',
SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(),
);
if (exists $self->{ssl_version}) {
$ssl_options{SSL_version} = $self->{ssl_version};
}
if (exists $self->{ssl_verify_mode}) {
$ssl_options{SSL_verify_mode} = $self->{ssl_verify_mode};
}
if (exists $self->{ssl_ca_path}) {
$ssl_options{SSL_ca_path} = $self->{ssl_ca_path};
}
lib/Mail/Sender.pm view on Meta::CPAN
$ssl_options{SSL_verifycb_name} = $self->{ssl_verifycb_name};
}
if (exists $self->{ssl_verifycn_schema}) {
$ssl_options{ssl_verifycn_schema} = $self->{ssl_verifycn_schema};
}
if (exists $self->{ssl_hostname}) {
$ssl_options{SSL_hostname} = $self->{ssl_hostname};
}
if ($self->{'debug'}) {
$res = IO::Socket::SSL->start_SSL(tied(*$s)->[0], %ssl_options);
}
else {
$res = IO::Socket::SSL->start_SSL($s, %ssl_options);
}
if (!$res) {
return $self->Error(_IO_SOCKET_SSL(IO::Socket::SSL::errstr()));
}
{
my $res = $self->_say_helo($s);
return $res if $res;
}
}
elsif ($self->{tls_required}) {
if ($TLS_notsupported) {
return $self->Error(_TLS_UNSUPPORTED_BY_ME($TLS_notsupported));
lib/Mail/Sender.pm view on Meta::CPAN
You may add support for other authentication protocols yourself.
=head2 auth_encoded
# mutating single attributes could get costly!
$sender = $sender->new({auth_encoded => 1});
my $auth_enc = $sender->{auth_encoded}; # reach in to grab
If set to a true value, L<Mail::Sender> attempts to use TLS (encrypted connection)
whenever the server supports it and you have L<IO::Socket::SSL> and L<Net::SSLeay>.
The default value of this option is true! This means that if L<Mail::Sender>
can send the data encrypted, it will.
=head2 authdomain
# mutating single attributes could get costly!
$sender = $sender->new({authdomain => 'bar.com'});
my $domain = $sender->{authdomain}; # reach in to grab
lib/Mail/Sender.pm view on Meta::CPAN
# -14 = connection not established. Did you mean MailFile instead of SendFile?
# -15 = no SMTP server specified
# -16 = no From: address specified
# -17 = authentication protocol not accepted by the server
# -18 = login not accepted
# -19 = authentication protocol is not implemented
# -20 = all recipients were rejected by the server
# -21 = file specified as an attachment cannot be read
# -22 = failed to open the specified debug file for writing
# -23 = STARTTLS failed (for SSL or TLS encrypted connections)
# -24 = IO::Socket::SSL->start_SSL failed
# -25 = TLS required by the specified options, but the required modules are not available. Need IO::Socket::SSL and Net::SSLeay
# -26 = TLS required by the specified options, but the server doesn't support it
# -27 = unknown encoding specified for the mail body, part or attachment. Only base64, quoted-printable, 7bit and 8bit supported.
my $on_errors = $sender->{on_errors}; # reach in to grab
say $Mail::Sender::Error; # contains a textual description of last error.
This option allows you to affect the way L<Mail::Sender> reports errors.
All methods return the C<$sender> object if they succeed.
C<< $Mail::Sender::Error >> C<< $sender->{'error'} >> and C<< $sender->{'error_msg'} >>
are set in all cases.
lib/Mail/Sender.pm view on Meta::CPAN
# mutating single attributes could get costly!
$sender = $sender->new({smtp => 'smtp.bar.com'});
my $smtp = $sender->{smtp}; # reach in to grab
The IP address or domain of your SMTP server.
=head2 ssl_...
The C<ssl_version>, C<ssl_verify_mode>, C<ssl_ca_path>, C<ssl_ca_file>,
C<ssl_verifycb_name>, C<ssl_verifycn_schema> and C<ssl_hostname> options (if
specified) are passed to L<IO::Socket::SSL/"start_SSL">. The default version is
C<TLSv1> and verify mode is C<IO::Socket::SSL::SSL_VERIFY_NONE>.
If you change the C<ssl_verify_mode> to C<SSL_VERIFY_PEER>, you may need to
specify the C<ssl_ca_file>. If you have L<Mozilla::CA> installed, then setting
it to C<< Mozilla::CA::SSL_ca_file() >> may help.
=head2 subject
# mutating single attributes could get costly!
$sender = $sender->new({subject => 'An email is coming!'});
my $subject = $sender->{subject}; # reach in to grab
lib/Mail/Sender.pm view on Meta::CPAN
=head2 tls_allowed
# mutating single attributes could get costly!
$sender = $sender->new({tls_allowed => 1}); # true, default
$sender = $sender->new({tls_allowed => 0}); # false
my $tls = $sender->{tls_allowed}; # reach in to grab
If set to a true value, L<Mail::Sender> will attempt to use TLS (encrypted
connection) whenever the server supports it. This requires that you have
L<IO::Socket::SSL> and L<Net::SSLeay>.
=head2 tls_required
# mutating single attributes could get costly!
$sender = $sender->new({tls_required => 1}); # true, require TLS encryption
$sender = $sender->new({tls_required => 0}); # false, plain. default
my $required = $sender->{tls_required};
If you set this option to a true value, the module will fail if it's unable to use TLS.
t/00-load.t view on Meta::CPAN
is($err, 'STARTTLS failed: crappola ', '_STARTTLS: proper string');
$num = undef; $err = undef;
($num,$err) = Mail::Sender::_STARTTLS('crappola', 'crappola');
is($num, -23, '_STARTTLS: proper number');
is($err, 'STARTTLS failed: crappola crappola', '_STARTTLS: proper string');
$num = undef; $err = undef;
($num,$err) = Mail::Sender::_IO_SOCKET_SSL();
is($num, -24, '_IO_SOCKET_SSL: proper number');
is($err, 'IO::Socket::SSL->start_SSL failed: ', '_IO_SOCKET_SSL: proper string');
$num = undef; $err = undef;
($num,$err) = Mail::Sender::_IO_SOCKET_SSL('crappola');
is($num, -24, '_IO_SOCKET_SSL: proper number');
is($err, 'IO::Socket::SSL->start_SSL failed: crappola', '_IO_SOCKET_SSL: proper string');
$num = undef; $err = undef;
($num,$err) = Mail::Sender::_TLS_UNSUPPORTED_BY_ME();
is($num, -25, '_TLS_UNSUPPORTED_BY_ME: proper number');
is($err, 'TLS unsupported by the script: ', '_TLS_UNSUPPORTED_BY_ME: proper string');
$num = undef; $err = undef;
($num,$err) = Mail::Sender::_TLS_UNSUPPORTED_BY_ME('crappola');
is($num, -25, '_TLS_UNSUPPORTED_BY_ME: proper number');
is($err, 'TLS unsupported by the script: crappola', '_TLS_UNSUPPORTED_BY_ME: proper string');
t/00-report-prereqs.dd view on Meta::CPAN
'Test::Pod::Coverage' => '1.08',
'Test::Pod::Spelling::CommonMistakes' => '1.000',
'Test::Spelling' => '0.12',
'Test::Version' => '1'
}
},
'runtime' => {
'recommends' => {
'Authen::NTLM' => '0',
'Digest::HMAC_MD5' => '0',
'IO::Socket::SSL' => '0',
'Mozilla::CA' => '0',
'Net::SSLeay' => '0'
},
'requires' => {
'Carp' => '0',
'Encode' => '0',
'Exporter' => '0',
'File::Basename' => '0',
'IO::Handle' => '0',
'IO::Socket::INET' => '0',
( run in 0.629 second using v1.01-cache-2.11-cpan-4d50c553e7e )