title: is there a way to attach a PDF FILE with Net::SMTP in Perl
body: <p>I'm trying to attach a pdf file on a multipart content email, yes I know i could use mime lite or a billion perl modules, but I'm limited to use perl 5.8.8 as it comes out of the box, so far I have </p>
  
  <pre><code>#!/usr/bin/perl
  use Net::SMTP;
  use MIME::Base64 qw( encode_base64 );
  use MIME::Base64 qw( decode_base64 );
  use strict;
  use warnings;
  
  my $from = 'az@xx.com';
  my $to = 'raxxxfael.xx@xxx.com';
  my $to2 = 'xx.xx@xxx.com';
  my $boundary = 'frontier';
  
  
  
  
  open my $Initial_File, '&lt;', "summary.pdf";
  binmode $Initial_File;
  open my $Initial_OutFile, '&gt;', "temp.pdf";
  my $buf;
  while ( read( $Initial_File, $buf, 60 * 57 ) ) {
      print $Initial_OutFile encode_base64( $buf );
  }
  
  close $Initial_OutFile;
  close $Initial_File;
  
  
  open INFILE, '&lt;', "temp.pdf";
  open my $final_output, '&gt;',"summary2.pdf";
  binmode $final_output;
  my $buffer;
  while ( $buffer = &lt;INFILE&gt; ) {
      print $final_output decode_base64( $buffer );
  }
  my @pdf = $final_output;
  close $final_output;
  close INFILE; 
  
  my $smtp = Net::SMTP-&gt;new('xx.xxx.com');
  $smtp-&gt;mail($from);
  $smtp-&gt;recipient($to,$to2, { SkipBad =&gt; 1 });
  $smtp-&gt;data();
  $smtp-&gt;datasend("Subject: Test Email \n");
  $smtp-&gt;datasend("MIME-Version: 1.0\n");
  $smtp-&gt;datasend("Content-type: multipart/mixed;\n\tboundary=".$boundary."\n");
  $smtp-&gt;datasend("\n");
  $smtp-&gt;datasend("--".$boundary."\n");
  $smtp-&gt;datasend("Content-type: text/plain\n");
  $smtp-&gt;datasend("Content-Disposition: quoted-printable\n");
  $smtp-&gt;datasend("\nTest From You \n");
  $smtp-&gt;datasend("--".$boundary."\n");
  $smtp-&gt;datasend("Content-Disposition: attachment; filename=summary2.pdf \n");
  $smtp-&gt;datasend("Content-Type: application/pdf; name=summary2.pdf ");
  $smtp-&gt;datasend("\n");
  $smtp-&gt;datasend("@pdf\n");
  $smtp-&gt;datasend("--".$boundary."--\n");
  $smtp-&gt;dataend();
  # $smtp-&gt;quit;   
  
  exit;
  </code></pre>
  
  <p>The email sends out correctly, but (obviously) when trying to open the pdf file it says it has an incorrect encoding, is there a way to buffer the PDF file to the attachment in a way that it send it out as it is ?</p>