## Open sendmail via pipe $fh = new FileHandle(); ## -t = Scan's the input for recipient headers. ## -oi = Set interactive delivery mode. ## -oem = Enable BerkNet processing, and mail back for errors unless ($fh->open("|/usr/lib/sendmail -t -oi -oem")) { ## Failed to open sendmail #error_log("Unable to open pipe for sendmail.", $!, $main::prog,'email_delivery', 'FATAL', 'ERROR'); print "Unable to open pipe for sendmail. $!, $main::prog,'email_delivery', 'FATAL', 'ERROR'"; return 0; ## failure ## } ## Build MIME message $message = MIME::Entity->build ( 'Type' => 'multipart/mixed', 'To' => $emailaddress, 'Subject' => $emailsubject, 'X-Mailer' => undef); ## Check if we received an object back unless (defined $message) { #error_log("MIME::Entity->build() failed to return an object reference.", "", $main::prog, 'email_delivery','FATAL', 'ERROR'); print "MIME::Entity->build() failed to return an object reference., $main::prog, 'email_delivery','FATAL', 'ERROR'"; return 0; ## failure ## } ## Attach a message body $message->attach(Data => 'Your data has been attached to this message.'); # Attach the file as an octet-stream $message->attach(Type => 'application/octet-stream', Path => $infile, Encoding => 'base64'); $message->print($fh); $fh->close();