develooper Front page | perl.beginners | Postings from January 2002

email word attachment from html form input

Thread Next
From:
katia goforth
Date:
January 8, 2002 21:19
Subject:
email word attachment from html form input
Message ID:
3C3BD20E.91B08C4B@mykatia.com
hello,

I am trying to take input email addresses from an html web form and
email and attachment to that email address.  I am using the MIME::Lite
module and have no problems when shortening the script to just the mail
portion and executing via command line.  The problem appears to be with
the input of variables.  I'm guessing my speculation of the problem wont
help as much as the actual code (otherwise it would be fixed, right?) so
here it is... :)

In error_log receive premature end of script headers

Here are the errors received if doing a -w:
Name "main::tsr_addy" used only once: possible typo at ipjustify.pl line
18.
Use of uninitialized value in read at ipjustify.pl line 5.

here is line 5:
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

here is line 18:
$tsr_addy = $form{'tsr_addy'};

Here is the entire script...(I apologize for the length...)
#!/usr/bin/perl

use MIME::Lite;

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;
        }

# Assign variables to arguments
$eu_addy = $form{'eu_addy'};
$tsr_addy = $form{'tsr_addy'};

$msg = MIME::Lite->new(
             From     =>'katia@zuperzayian.com',
             To       =>'$eu_addy',
             Bcc      =>'$tsr_addy',
             Subject  =>'test message',
             Type     =>'TEXT',
             Data     =>'This is a test, i repeat only a test',
             );
$msg->attach(Type     =>'application/octet-stream',
             Encoding =>'base64',
             Path     =>'test.doc',
             );
$msg->send;

# Print HTML Out
print "Content-type: text/html\n\n";
print <<"END";
<html>
<head>
   <title>Word Doc Sent!!</title>
</head>
<br>
<center>
<br><br>The document has been successfully sent to
END
print $eu_addy;
print <<"**END**";
To send another form click back.
</center>
</body>
</html>
**END**

Here is just emailing using MIME::Lite (works... trying to dissect the
problem)
#!/usr/bin/perl

use MIME::Lite;

$msg = MIME::Lite->new(
             From     =>'katia@zuperzayian.com',
             To       =>'kgoforth@covad.com',
             Subject  =>'test message',
             Type     =>'TEXT',
             Data     =>'This is a test, i repeat only a test',
             );
$msg->attach(Type     =>'application/octet-stream',
             Encoding =>'base64',
             Path     =>'test.doc',
             );
$msg->send;

Any help or insight you can provide is greatly appreciated.  I don't
know if this doesn't make sense cuz i've been staring at it for a while,
or because i'm not feeling well.  Either way thank you for the insight
or links to information that can help..

Thank you
-katia


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About