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
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.