## without authorization
sub send_mail {
my $to = $_[0];
my $subject = $_[1];
my $body = $_[2];
%mail = (To => $to,
From => 'fromuser@somehost.com', ## << from
Subject => $subject,
Message => $body,
);
$mail{Smtp} = 'smtpserver.somedomain.com'; # << SMTP server
sendmail(%mail) or die $Mail::Sendmail::error;
print "Sendmail log:\n", $Mail::Sendmail::log;
}
Usage:
&send_mail('mailbox@somehost.com', $email_subject, $email);