DaWolf has asked for the wisdom of the Perl Monks concerning the following question:

Hi There
I'm trying to make a script that sends an file attached to a certain e-mail address. The file is local on my machine, wich is not the machine where the site and the script are hosted.
I'm getting the following error message:

Software error:
C:\foo\foo.txt: not readable

Is that happening 'cause the server doesn't support MIME::Lite? Or is that an error in the code (see below). If is the first alternative, is there any solution to achieve this without the help of a module?
Here is the code:
#!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser); use MIME::Lite; require './cgi-lib.pl'; read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } $from = $FORM{'from'}; $to = $FORM{'to'}; $subject = $FORM{'subject'}; $file = FORM{'file'}; $page = $FORM{'page'}; my $msg = MIME::Lite->new ( From => '$from', To => '$to', Subject => '$subject', Type => 'multipart/mixed'); $msg->attach( Type =>'BINARY', Path =>"$file"); $msg->send; print "Location: $page\n\n";

Thanks in advance,

Er Galvão Abbott
a.k.a. Lobo, DaWolf
Webdeveloper

Replies are listed 'Best First'.
Re: Problems with MIME::Lite
by Beatnik (Parson) on Apr 12, 2001 at 12:39 UTC
    You might want to forget about cgi-lib.pl since CGI.pm mimicks its behavious completly.

    Greetz
    Beatnik
    ... Quidquid perl dictum sit, altum viditur.
Re: Problems with MIME::Lite
by jepri (Parson) on Apr 12, 2001 at 12:42 UTC
    For those who come after, you can learn how to upload a file to the server here

    ____________________
    Jeremy
    I didn't believe in evil until I dated it.

Re: Problems with MIME::Lite
by bjelli (Pilgrim) on Apr 12, 2001 at 15:20 UTC
Re: Problems with MIME::Lite
by Desdinova (Friar) on Apr 12, 2001 at 20:24 UTC
    For starters i suggest reading this node use cgi or die; on why that cgi-lib.pl line is a bad thing. The next thing i see right off the bat is this line:
    $file = FORM{'file'};
    which should read
    $file = $FORM{'file'};
    I can't really test it becaue I dont have that cgi-lib file on my system (another good reason on use Std modules).
Re: Problems with MIME::Lite
by iguane (Beadle) on Apr 12, 2001 at 12:32 UTC
    It's normal that you could not send your attachement. You must export your local file on the machine where your perl traitment is installed. For that you have different way:
    - first export by FTP ( use module NET::FTP )
    - second you could do a script on remote machine to upload your file ( but you will must send this file by manipulation on LWP ).
    The second solution look more difficult that the first.
    Sorry , For this bad reflexion , i dont' read all of the comment. Perhaps have you a right-problem on this file ...