csorensen has asked for the wisdom of the Perl Monks concerning the following question:
I need to accept a form submission,
capture the name of a file (name is passed in the cgi
param), extract the user's email address
from the form data, save the form data to a log file,
attach the file whose name corresponds to the name
passed in the cgi param and email it to the user.
I think I've captured and regexed the form data properly, I've written the data to a hash, and opened the pipe to sendmail. The questions are: are there any obvious problems in the code so far AND how the heck do you attach a file to sendmail ??
I think I've captured and regexed the form data properly, I've written the data to a hash, and opened the pipe to sendmail. The questions are: are there any obvious problems in the code so far AND how the heck do you attach a file to sendmail ??
here's the code I have now .. with comments removed for space
use strict; use CGI; $sendmail = '/usr/lib/sendmail'; $file = param('file'); $formdata=<STDIN>; $formdata=~s/\s+$//; foreach (split(/&/, $formdata)) { ($name, $value)=split(/=/, $_); $name=~s/\+/ /g; $name=~s/%([0-9|A-F]{2})/pack(C,hex($1))/eg; $value=~s/\+/ /g; $value=~s/%([0-9|A-F]{2})/pack(C,hex($1))/eg; $formash{$name} = $value; } $receiver = $formash{email}; open(SENDMAIL, "|$sendmail") or die "Cannot open $sendmail: $!"; print SENDMAIL "To: $receiver \n"; print SENDMAIL "From: info\@constellar.com \n"; print SENDMAIL "Subject: Whitepapers Request \n"; close(SENDMAIL);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: extract data from a form .. and attach a file in sendmail
by KM (Priest) on Jun 30, 2000 at 21:52 UTC | |
Re: extract data from a form .. and attach a file in sendmail
by merlyn (Sage) on Jun 30, 2000 at 21:49 UTC | |
Re: extract data from a form .. and attach a file in sendmail
by csorensen (Beadle) on Jul 01, 2000 at 00:22 UTC | |
Re: extract data from a form .. and attach a file in sendmail
by chromatic (Archbishop) on Jul 01, 2000 at 04:34 UTC | |
by csorensen (Beadle) on Jul 01, 2000 at 07:21 UTC | |
Re: extract data from a form .. and attach a file in sendmail
by Anonymous Monk on Jul 02, 2000 at 02:18 UTC | |
Re: extract data from a form .. and attach a file in sendmail
by Anonymous Monk on Jul 01, 2000 at 05:39 UTC |
Back to
Seekers of Perl Wisdom