I need to connect to a Microsoft Exchange server, and the only module I've found which can achieve this is Net::SMTP::TLS. I'm able to send the emails, however, I'm unable to understand the way it wants me to attach a file. Unlike MIME::Lite, it doesn't simply attach the file and send. It looks like it's expecting me to write to the attachment after having attached it to the email.
Q: Is there not some way I can just attach the file? Should I be using some other module to work with Microsoft Exchange?
Please see my code below, as well as the link to an Ars Technica discussion on this topic. This code seems to put what is supposed to be the body of the email into the attached file.
$smtp->mail($from_email);
$smtp->to(@to_email_arr);
$smtp->cc(@cc_email_arr);
$smtp->data;
$smtp->datasend("Subject: $subject\n");
$smtp->datasend("To: $to_email\n");
$smtp->datasend("CC: $cc_email\n");
$smtp->datasend("From: $from_email\n");
$smtp->datasend("MIME-Version: 1.0\n");
$smtp->datasend("Content-Disposition: attachment; filename=\"$filename\"n");
$smtp->datasend("Content-Type: application/text; name=attachment.txt ");
$smtp->datasend();
$smtp->datasend($body_msg);
$smtp->dataend;
$smtp->quit;