Click to See Complete Forum and Search --> : I'm stumped (sendmail)


damainman77
07-15-2003, 08:51 AM
I have written a CGI script (in Perl) that prints a big block of html text (a web form), gives a confirmation message to the user. and now I want the script to send me an email with all of the values put in by the user. Here is the beggining of the script, that is used to produce the confirmation message, as well as to define $recipient as my email address and the location of sendmail.



#!/usr/bin/perl -w

use CGI ':standard';
print header;
$mailprog = '/usr/sbin/sendmail';
$recipient = 'myemail@somewhere.com';
print start_html('Code 974 New User Account Application Form');
if (param()) {
print '<body bgcolor="#FFDAB9"><a href="http://hsb.gsfc.nasa.gov"><img SRC="gif/hydro.sm.gif" align="left" valign="top"></a><a href="http://www.nasa.gov"><img SRC="gif/NASAlogo.gif" valign="top" align="right"></a></align>
<center><h1>Thank You</h1>';
print "<br><i><h2>Your information has been succesfully submitted</h2></i><br><hr><br><br></center>";
my @params = param();
foreach my $parameter(@params) {
print "<b>", $parameter,"</b>", " - ", param($parameter),"<br>";
}
print '<br><center><font size="+2">To resubmit, please click <a href="http://lshp.gsfc.nasa.gov/status/userapp.cgi">here</a></font></center><br><br>';
print '<hr color="" size=5 width=90%>
--------------------------------------------------------------------

I'm not going to actually paste the entire source for the form in this message, because it is unneccesary, but I will give you the names of all the fields. FirstName, LastName, GSFCIDNumber, PhoneNumber, FaxNumber, Location, email, IP_HostName, Title, Leader, SGI, DECAlpha, PCs, UserName, AlternateUserName, Comments.


---------------------------------------------------------------------

My boss suggested using something like form.FirstName.value to show the value for FirstName, but I'm not sure how this works. Can someone tell me, possibly based on the opening CGI that I provided how I can put in a script to send me an email with form results at the end of the file? Here is what I'm starting with.........

---------------------------------------------------------------------

open (MAIL, "|$mailprog -t 'sambrin' ") || die "cannot open $mailprog!\n";

print MAIL <<EOF;

#someone please tell me what to put here....

Close (MAIL);

jimr451
07-15-2003, 11:58 AM
Well, I don't think variables get interpreted when you do something like:

print << EOF


So, I'd suggest following this type of format:

print MAIL "From: $mail_from\n";
print MAIL "To: $mail_to\n";
print MAIL "Subject: This is the subject\n";

foreach my $parameter(@params) {
print MAIL "<b>", $parameter,"</b>", " - ", param($parameter),"<br>\n";
}




Hope this helps!

-Jim

Jeff Mott
07-15-2003, 12:59 PM
Well, I don't think variables get interpreted when you do something like:
print << EOFThey do.print MAIL "From: $mail_from\n";
print MAIL "To: $mail_to\n";
print MAIL "Subject: This is the subject\n";Don't forget that there must be a blank line between the header and the message body.print MAIL "From: $mail_from\n",
"To: $mail_to\n",
"Subject: This is the subject\n\n";foreach my $parameter(@params) {
print MAIL "<b>", $parameter,"</b>", " - ", param($parameter),"<br>\n";
}An e-mail message without a Content-Type defaults to text/plain and should not contain HTML markup.for (params()) {
print MAIL $_, ' -> ', param($_), "\n";
}My boss suggested using something like form.FirstName.value to show the value for FirstName, but I'm not sure how this worksDon't dwell over it too much, your boss is thinking in the wrong language. :)