Well, first $data_file does not contain your file but its path!
Then, open should have "<" like this : open(DATA, "<$data_file")
Then, you MUST encode it in base64 :
use MIME::Base64; # beginning of your program
encode_base64(...) # to encode.
So to conclude :
Code:
use MIME::Base64; # beginning of your program
...
my $zipdata; # don't forget to declare it
open(DATA, "<$data_file") || die("Could not open the file ($!)");
read(DATA, $zipdata, (stat($data_file))[7] ); # this reads the whole file and puts its content into $zipdata
close(DATA);
...
$smtp->datasend("Content-Transfer-Encoding: base64\n"); # (remove the space)
$smtp->datasend("Content-Type: application/zip; name=\"$attachFile\"\n");
$smtp->datasend("Content-Disposition: attachment; filename=\"$attachFile\"\n");
$smtp->datasend("\n");
$smtp->datasend( encode_base64($zipdata)."\n" );
$smtp->datasend("--$boundary--\n");
PS: I hope your smtp module splits the lines!
Because in the smtp protocol, the lines are limited.
If you get a HUGE line of base64, you MUST cut it in pieces of 76 chars.