sub emailFile { my $to = shift; my $subject = shift; my $content = shift; my $filename = shift; my $nette_naam = shift; my $command = "|/usr/lib/sendmail -f $from $to"; open(MAIL, $command) || die("Can't open sendmail!!\n"); print MAIL "To: $to\r\n"; print MAIL "Subject: $subject\r\n"; print MAIL "MIME-Version: 1.0\r\n"; print MAIL "Content-Type: multipart/mixed; boundary=\"----=_NextPart_000_002C_01C2C170.A5EE7000\"\r\n"; print MAIL "\r\n"; print MAIL "This is a multi-part message in MIME format.\r\n"; print MAIL "\r\n"; print MAIL "------=_NextPart_000_002C_01C2C170.A5EE7000\r\n"; print MAIL "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n"; print MAIL "Content-Transfer-Encoding: 8bit\r\n"; print MAIL "\r\n"; print MAIL $content . today() . "\r\n"; print MAIL "\r\n"; if (open(FILE, $filename)) { print MAIL "------=_NextPart_000_002C_01C2C170.A5EE7000\r\n"; print MAIL "Content-Type: application/octet-stream; name=\"$nette_naam\"\r\n"; print MAIL "Content-Transfer-Encoding: 8bit\r\n"; print MAIL "Content-Disposition: attachment; filename=\"$nette_naam\"\r\n"; print MAIL "\r\n"; while () { print MAIL $_; } close (FILE); } print MAIL "------=_NextPart_000_002C_01C2C170.A5EE7000--\r\n"; print MAIL "\r\n"; close(MAIL); }