sub mailsend {

my ($from,$to,$subject,$emailmsg) = @_ ;
   
use Mail::Sendmail;

#-------------------------------------------------------------------------------

my $boundary = "====" . time() . "====";

#---------------------------------------------------------------------------------

my %mail = () ;

# if ($username eq 'rory') { $to = 'rory@kre8it.co.za' ; }
    
unless ($from) { $from = qq(Film Freight <filmfreight\@filmfreight.co.za>) ; }
# unless ($from) { $from = 'Film Freight <rory@kre8it.co.za>' ; }

%mail = (
         smtp    => 'localhost',
         From    => $from,
         To      => $to,
         Subject => $subject
         );

#---------------------------------------------------------------------------------

$mail{'content-type'} = "multipart/alternative; boundary=\"$boundary\"";

# <img alt="filmfreight" src="data:image/jpeg;base64,[encoded data, 28916 characters]" border="0">


$boundary = '--'.$boundary;

$mail{body} = <<END_OF_BODY;
$boundary
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body>
<p>
<img alt="" src="https://$ENV{SERVER_NAME}/img/email_logo.jpg" border="0">
</p>
<p>
$emailmsg
</p>
</body>
</html>

$boundary--

END_OF_BODY

sendmail(%mail) ;

# $mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\"";

# $boundary = '--'.$boundary;

# $mail{body} = <<END_OF_BODY;
# $boundary
# Content-Type: text/html; charset=ISO-8859-1
# Content-Transfer-Encoding: 7bit
# <html>
# <head>
# <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
# <title>$subject</title>
# </head>
# <body>
# $email_msg
# </BODY>
# </HTML>

# $boundary--

# END_OF_BODY

# sendmail(%mail) ;
   
} #------------------------------------------------------------------------------------

1;
