Perl Mail
Net::SMTP
# we need: Authen::SASL
use Net::SMTP;
my $smtp_server = "";
my $smtp_server_account = "";
my $smtp_server_passwd = "";
my $smtp_from = "";
my $smtp_to = "";
my $smtp_cc = "";
my $smtp_bcc = "";
my $smtp_subject = "";
my $smtp_message = "";
my $smtp = Net::SMTP->new($smtp_server, Debug => 0);
$smtp->auth($smtp_server_account, $smtp_server_passwd);
$smtp->mail($smtp_from);
$smtp->to($smtp_to);
$smtp->cc($smtp_cc);
$smtp->bcc($smtp_bcc);
$smtp->data();
$smtp->datasend("From: $smtp_from\n");
$smtp->datasend("To: $smtp_to\n");
$smtp->datasend("Subject: $smtp_subject\n");
$smtp->datasend("\n");
$smtp->datasend("$smtp_message");
$smtp->dataend();
$smtp->quit;
Mail::Sender
# we need: Net::SMTP, Authen::SASL
use Mail::Sender;
$Mail::Sender::NO_X_MAILER = 1;
$Mail::Sender::NO_MESSAGE_ID = 1;
$Mail::Sender::SITE_HEADERS='X-Mailer: NONAME';
my $smtp_server = '';
my $smtp_server_account = '';
my $smtp_server_passwd = '';
my $smtp_from = '';
my $smtp_to = '';
my $smtp_cc = 'adr1,adr2';
my $smtp_bcc = '';
my $smtp_subject = 'foo';
my $smtp_message = "bar\n";
my $smtp_attach = '';
open my $DEBUG, "> /tmp/Mail_Sender_debug.txt"
or die "Can't open the debug file: $!\n";
my $smtp = new Mail::Sender {
smtp => $smtp_server,
from => $smtp_from,
auth => 'LOGIN',
authid => $smtp_server_account,
authpwd => $smtp_server_passwd,
on_errors => undef,
debug => $DEBUG,
} or die "Can't create the Mail::Sender object: $Mail::Sender::Error\n";
if ( -e "$smtp_attach" ) {
$smtp->MailFile( {
to => $smtp_to,
cc => $smtp_cc,
bcc => $smtp_bcc,
subject => $smtp_subject,
msg => $smtp_message,
file => $smtp_attach
} ) or print $Mail::Sender::Error;
}
else {
$smtp->MailMsg( {
to => $smtp_to,
cc => $smtp_cc,
bcc => $smtp_bcc,
subject => $smtp_subject,
msg => $smtp_message,
} ) or print $Mail::Sender::Error;
}
$smtp->Close;
IO::Socket::SSL->start_SSL failed
tnx 2 Ether
IO::Socket::SSL->start_SSL failed: SSL connect attempt failed with unknown error error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
#################################################
# begin bugfix IO::Socket::SSL #
# hint: install Crypt::SSLeay; #
#+#use IO::Socket::SSL qw(debug3);
use IO::Socket::SSL;
use Net::SSLeay;
BEGIN {
IO::Socket::SSL::set_ctx_defaults(
verify_mode => Net::SSLeay->VERIFY_PEER(),
ca_file => "/usr/share/doc/packages/perl-Crypt-SSLeay/certs/ca-bundle.crt",
);
}
# end bugfix IO::Socket::SSL #
#################################################
use Mail::Sender;