deg01004 has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to send a .xlsx via SMTP. There is content in the email that is sent but i think there is something wrong with the encoding. Whenever i try to open the .xlsx from the email i get the message the file format or file extension is not valid and to verify that it has not bee corrupted.
I realized that something like mimelite might be easier but i would like to figure out the SMTP route as well.
Any help would be appreciated
my $to_email = "xxx\@imail.org"; our $smtp = Net::SMTP->new("smtp.xx.xx.com",Debug=>1); $smtp->mail("xxx\@imail.org"); $smtp->recipient("$to_email"); $smtp->data(); $smtp->datasend("To: $to_email\n"); $smtp->datasend("Cc: xxx\@imail.org\n"); $smtp->datasend("From: xxx\@imail.org\n"); $smtp->datasend("Subject: Annual Access Reviews\n"); $smtp->datasend("MIME-Version: 1.0\n"); $smtp->datasend("Content-Type: multipart/mixed; boundary= \"*B +CKTR*\"\n\n"); # Send the body. $smtp->datasend("--*BCKTR*\n"); $smtp->datasend("Content-Type: text/html\n\n"); $smtp->datasend("@$distinct_manager[3], \n\n"); $smtp->datasend("<div><b>As a manager your task at hand</b> is + the following:</div>"); $smtp->datasend("<p>These user access reviews must be complete +d and returned by 12/18/2015 XX.XX.2015(6).</p>"); $smtp->datasend("<p><b>Please email the completed spreadsheets + to emailaddress\@imail.org.</b></p>"); $smtp->datasend("<p><b>Please go to http://some_internal_websi +te on how to upload your completed spreadsheet(s).</b></p>"); $smtp->datasend("<div>Thank You,</div>"); $smtp->datasend("<div>Manager, ISSA Identity and Access Manage +ment</div>"); $smtp->datasend("\n"); $smtp->datasend("--*BCKTR*\n"); $smtp->datasend("Content-Type: application/vnd.openxmlformats- +officedocument.spreadsheetml.sheet; name=\"$attachfile\" \n"); $smtp->datasend("Content-Transfer-Encoding: base64"); $smtp->datasend("Content-Disposition: attachment; filename =\" +$attachfile\"\n\n"); $smtp->datasend("\n"); open(DAT, $attachfile) || die("Could not open text file!"); binmode(DAT); my $data = do { local $/; <DAT> }; close DAT; $smtp->datasend($data); $smtp->datasend("\n"); $smtp->datasend("\n"); $smtp->dataend(); $smtp->quit;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Net:::SMTP and Attaching a xlsx
by Anonymous Monk on Nov 21, 2015 at 03:31 UTC | |
|
Re: Net:::SMTP and Attaching a xlsx
by deg01004 (Initiate) on Nov 21, 2015 at 04:52 UTC | |
by Anonymous Monk on Nov 21, 2015 at 06:31 UTC | |
by Anonymous Monk on Nov 21, 2015 at 07:16 UTC | |
by Anonymous Monk on Nov 21, 2015 at 07:37 UTC | |
by Anonymous Monk on Nov 21, 2015 at 07:47 UTC |