I am using the below script to email a ZIP file attachment, but when I receive the email and try to open the zip file I receive error "The archive is either in unknown format or damaged". What am I doing wrong when trying to email the ZIP attachment?? This script is being run on Windows 2000. Any help is appreciated.
#!c:\perl\bin\perl #-w
#
#use strict;
use Time::Format qw(%time %strftime %manip);
use Net::SMTP;
use File::Copy;
$ctime="$time{'hh:mm'}";
$yesterday="$time{'yyyymmdd', time-24*60*60}";
$lastmonth="$month_len[$month - 1]";
$cdate="$time{'yyyy.mm.dd'}";
$file1="OPTUS.ECBOT.ZIP";
$log="email.log";
my $subject = "subject";
my $mailfrom = "email@mail.com";
my $mailto = "email@mail.com";
print "Sending message to $mailto\n";
my $stat_filename = "email.log";
my ($serverName) = "mailserver";
my $smtp = Net::SMTP->new($serverName, Timeout => 60);
# die "Couldn't connect to server $smtp" unless $smtp;
$smtp->mail( $mailfrom );
$smtp->to( $mailto );
$smtp->data();
$smtp->datasend("From: ", $mailfrom, "\n");
$smtp->datasend("Subject: $subject\n");
$smtp->datasend("MIME-Version: 1.0\n");
$smtp->datasend("Content-Disposition: attachment; filename=\"OPTUS.ECB
+OT.ZIP\"\n");
$smtp->datasend("Content-Type: application/zip; name= $file1 ");
$smtp->dataend();
$smtp->quit();
exit;
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.