Q:
How to send mail using perl on windows without sendmail?
A:
You need Mail::Sender module and available SMTP Server
e.g.
Simple single part message
$sender = new Mail::Sender {
smtp => 'mail.yourISP.com',
from => 'somebody@somewhere.com',
on_errors => undef,
}
or die "Can't create the Mail::Sender object\n";
$sender->Open({
to => 'mama@home.org, papa@work.com',
cc => 'somebody@somewhere.com',
subject => 'Sorry, I\'ll come later.'
})
or die "Can't open the message: $sender->{'error_msg'}\n";
$sender->SendLineEnc("I'm sorry, but thanks to the lusers,
I'll come at 10pm at best.");
$sender->SendLineEnc("\nHi, Jenda");
$sender->Close()
or die "Failed to send the message: $sender->{'error_msg'}\n";
read more
here
yet another good option is
Email::Sender module
usage:
my $message = Email::MIME->create( ... );
use Email::Sender::Simple qw(sendmail);
use Email::Sender::Transport::SMTP qw();
use Try::Tiny;
try {
sendmail(
$message,
{
from => $SMTP_ENVELOPE_FROM_ADDRESS,
transport => Email::Sender::Transport::SMTP->new({
host => $SMTP_HOSTNAME,
port => $SMTP_PORT,
})
}
);
} catch {
warn "sending failed: $_";
};