sub sendfile { my $email = $_[0]; my $from = $_[1]; my $subject = $_[2]; my $message = $_[3]; my $file = $_[4]; ($date,$boundary) = &boundary; #print "Content-type: text/html\n\n"; #print $_[4]; #exit; my $file_cont=encode_base64($file); #my $file_cont=encode_base64($line); $length=length($message); $send = qq~Content-Transfer-Encoding: binary Content-Type: multipart/mixed; boundary="$boundary" MIME-Version: 1.0 Date: $date From: $from To: $email Subject: $subject This is a multi-part message in MIME format. --$boundary Content-Disposition: inline Content-Length: $length Content-Transfer-Encoding: binary Content-Type: text/plain $message --$boundary Content-Disposition: inline; filename="$file" Content-Transfer-Encoding: base64 Content-Type: application/zip; name="$file" $file_cont --$boundary-- ~; $smtp = Net::SMTP->new($mailhost); $smtp->mail($_[1]); $smtp->to($_[0]); $smtp->data(); $smtp->datasend("To: $_[0]\n"); $smtp->datasend("From: $_[1]\n"); $smtp->datasend("Subject: $_[2]\n\n"); $smtp->datasend("\n"); #$smtp->datasend("$_[3]\n"); $smtp->datasend("$_[4]\n"); $smtp->datasend("$send\n"); $smtp->dataend(); $smtp->quit; # open(MAIL,"|$mailprog -t"); # print MAIL $send; # close(MAIL); }