my $data_file="C:\\test\\test.txt"; open(DATA, $data_file) || die("Could not open the file"); my @file_content = DATA; close(DATA); my $smtp = Net::SMTP->new('company-smtp.net', Debug => 1, Timeout => 60) || print "couldn't create smtp obj: #$!"; $smtp->mail('ich@ich.com'); $smtp->to('ich@ich.com'); $smtp->data(); $smtp->datasend("To: Ich"); $smtp->datasend("From: Du"); $smtp->datasend("Subject: Testmail\n"); $smtp->datasend("MIME-Version: 1.0\n"); $smtp->datasend("Content-Disposition: attachment; filename=\"C:\\test\\test.txt\"\n"); $smtp->datasend("Content-Type: application/txt; name= test.txt "); $smtp->datasend(); $smtp->datasend($file_content); $smtp->dataend; $smtp->quit;