### Create a new multipart message: $from = 'me@myworld.com'; $email = 'you@yourworld.com'; $msg = MIME::Lite->new( From =>"$from", To =>"$email", Subject =>"View User Report Results", Type =>'text/plain', Data =>"$data" ) || die "Error Creating MIME Body: $!\n\n"; # Attach the HTML document if the email is not empty if ($TheDocument2 !~ /E-mail.+$/) { # FIRST, CREATE A NEW DATA FILE my $gzip = '/bin/gzip'; my $unzipf = '/usr/temp/reports/YourResults.txt'; my $zipf = '/usr/temp/reports/YourResults.txt.gz'; open (UNZIPPED, ">$unzipf") || die "Cant prepare the unzipped file $unzipf\n\n"; $script{guts} =~ s/\n/\r\n/g; print UNZIPPED $script{guts}; close (UNZIPPED); # NOW ZIP THE FILE UP! system ("gzip -f $unzipf"); # OPEN THE ZIPPED FILE, AND GET DATA FROM IT undef $/; # NOW ATTACH THE ZIPPED FILE TO THE EMAIL! $msg->attach( #Type =>'application/x-gzip', Type =>'application/zip', Disposition =>'attach', #Data =>"$zip_data", Path =>"$zipf", Filename =>'YourResults.txt.gz' ) || die "Error Creating MIME Attachment: $!\n\n";; # DELETE THE ZIP FILE system ("rm -f $zipf"); } #$msg->send(); # I WISH TO SEND THIS VIA SMTP! my $message_body = $msg->body_as_string(); # Set this variable to your smtp server name my $ServerName = 'mail.policy.net'; my $smtp = Net::SMTP->new($ServerName) || die "Couldn't connect to server"; $smtp->mail ( $from ); $smtp->to ( $email ); $smtp->data(); $smtp->datasend($message_body); $smtp->dataend(); # Close the connection $smtp->quit();