#!/usr/bin/perl use strict; use warnings; use Mail::Sender; ## use Carp (); ## local $SIG{__WARN__} = \&Carp::cluck; BEGIN { my $b__dir = (-d '/home2/avantclo/perl'?'/home2/avantclo/perl':( getpwuid($>) )[7].'/perl'); unshift @INC,$b__dir.'5/lib/perl5',$b__dir.'5/lib/perl5/x86_64-linux-thread-multi',map { $b__dir . $_ } @INC;} my $user = 'webmaster@mydomain.org'; my $pass = 'TheRightPassword'; my $mlserver='mail.mydomain.org'; my $replyaddey='info@mydomain.org'; my $smtpaddey= 'localhost'; my $to='devmail@mydomain.org'; my $from_name='Webmaster'; my $from_email='webmaster@mydomain.org'; my $subject='smtp-ssl-auth test with Mail Sender module'; my $html="Test HTML content"; my $debugon = 1; my $debugoff = 0; my $portnum = 465; my $errorset = "code"; my $keepconn = 1; my $tlsreq = 1; $Mail::Sender::NO_X_MAILER = 1; open my $DEBUG, ">> ../../test/testsender1debugfile.txt" or die "Can't open the debug file: $!\n"; my $smtps = Mail::Sender->new({ smtp=>($mlserver), port=>($portnum), authid=>($user), authpwd=>($pass), from=>($from_email), reply=>($replyaddey), debug=>($debugon), on_errors => ($errorset), keepconnection=>($keepconn), TLS_allowed=>($tlsreq)}); $smtps->Open({ to=>($to), from=>($from_email), subject=>($subject)}); defined (ref $smtps) or die "Failed to open the message: $smtps->{'error_msg'}\n"; $smtps->SendLineEnc($html); $smtps->SendLineEnc("This will be the body of the message.\n"); $smtps->SendLineEnc("\n--\nVery Official Looking .sig here\n"); if ($Mail::Sender::Error eq '') { print "Test message has been sent\n"; } else { die "Failed to send the message: $smtps->{'error_msg'}\n"; } $smtps->Close();