sub sendSMTPMail {
# send a mail with SMTP server
# parameters:
# 0 : smtp (outgoing) mailserver
# 1 : smtp user login
# 2 : smtp user password
# 3 : sender name
# 4 : sender email
# 5 : recipient email
# 6 : message subject
# 7 : email message
my $server = shift;
my $user = shift;
my $pass = shift;
my $sendername = shift;
my $senderemail = shift;
my $recipient = shift;
my $subject = shift;
my $message = shift;
print "server:$server
\n";
print "user:$user
\n";
print "pass:$pass
\n";
print "sendername:$sendername
\n";
print "senderemail:$senderemail
\n";
print "recipient:$recipient
\n";
my $smtp = Net::SMTP->new($server);
if ( $smtp ) {
$smtp->auth("$user","$pass");
$smtp->mail("$senderemail");
$smtp->recipient($recipient);
$smtp->data();
$smtp->datasend("To: $recipient\n");
$smtp->datasend("From: \"$sendername\" <$senderemail>\n");
$smtp->datasend("Subject: $subject\n");
$smtp->datasend("\n");
$smtp->datasend("$message\n");
$smtp->dataend();
$smtp->quit;
} else {
print "Could not contact smtp mail server $server\n";
}
}