stephenc
12-27-2002, 07:05 PM
I'm trying to configure formmail, but I think I'm on the wrong track.
The URL's of the files are -
http://www.sitedesigns4u.co.uk/formmail.html
http://www.sitedesigns4u.co.uk/cgi-bin/formmail.cgi
Am I correct in thinking that all I need to do is -
1 Edit formmail.html line
<FORM ACTION="http://www.sitedesigns4u.co.uk/cgi-bin/formmail.cgi" METHOD=POST> to the address where I upload the formmail.cgi script on my server.
2 Upload it in Ascii and chomod it to 755.
3 Edit formmail.cgi shebang line.
4 Edit formmail.cgi
open(MAIL, "|/usr/sbin/sendmail -t") || Error ('open', 'mail program');
to my host's path to sendmail.
5 Upload it in Ascii and chomod it to 755.
6 Run the formmail.html
Its just that the script will not run at all. Am I totally on the wrong line of thinking here?
Stephen
code is as follows for both -
Formmail.cgi -
#!/usr/bin/perl -wT
use strict;
use CGI ':standard';
my ($to, $from, $subject, $contents);
print "Content-type:text/html\n\n";
#$to = param('to');
$from = param('from');
$subject = param('subject');
$contents = param('contents');
open(MAIL, "|/usr/sbin/sendmail -t") || Error ('open', 'mail program');
print MAIL "To: stephen\@sitedesigns4u.co.uk \nFrom: $from\n";
print MAIL "Subject: $subject\n";
print MAIL "$contents\n";
close(MAIL);
print "Thanks for your comments and feedback.";
sub Error {
print "The server can't $_[0] the $_[1]: $! \n";
exit;
}
formmail.html -
<HTML>
<HEAD>
<TITLE>Send e-mail to Stephen</TITLE>
</HEAD>
<BODY>
<FORM ACTION="http://www.sitedesigns4u.co.uk/cgi-bin/formmail.cgi" METHOD=POST>
<b><font size=+1>Write an email:</font></b>
<table border=0>
<tr><td align=right>To: </td><td><INPUT TYPE="text" NAME="to"></td></tr>
<tr><td align=right>From: </td><td><INPUT TYPE="text" NAME="from"></td></tr>
<tr><td align=right>Subject: </td><td><INPUT TYPE="text" NAME="subject"></td></tr>
<tr><td align=right>Contents: </td><td><TEXTAREA NAME="contents" ROWS=4 COLS=40></TEXTAREA></td></tr>
<tr><td> </td><td><INPUT TYPE="submit" VALUE="Send e-mail"> <INPUT TYPE="reset" VALUE="Erase e-mail"></td></tr>
</table></FORM>
</BODY>
</HTML>
The URL's of the files are -
http://www.sitedesigns4u.co.uk/formmail.html
http://www.sitedesigns4u.co.uk/cgi-bin/formmail.cgi
Am I correct in thinking that all I need to do is -
1 Edit formmail.html line
<FORM ACTION="http://www.sitedesigns4u.co.uk/cgi-bin/formmail.cgi" METHOD=POST> to the address where I upload the formmail.cgi script on my server.
2 Upload it in Ascii and chomod it to 755.
3 Edit formmail.cgi shebang line.
4 Edit formmail.cgi
open(MAIL, "|/usr/sbin/sendmail -t") || Error ('open', 'mail program');
to my host's path to sendmail.
5 Upload it in Ascii and chomod it to 755.
6 Run the formmail.html
Its just that the script will not run at all. Am I totally on the wrong line of thinking here?
Stephen
code is as follows for both -
Formmail.cgi -
#!/usr/bin/perl -wT
use strict;
use CGI ':standard';
my ($to, $from, $subject, $contents);
print "Content-type:text/html\n\n";
#$to = param('to');
$from = param('from');
$subject = param('subject');
$contents = param('contents');
open(MAIL, "|/usr/sbin/sendmail -t") || Error ('open', 'mail program');
print MAIL "To: stephen\@sitedesigns4u.co.uk \nFrom: $from\n";
print MAIL "Subject: $subject\n";
print MAIL "$contents\n";
close(MAIL);
print "Thanks for your comments and feedback.";
sub Error {
print "The server can't $_[0] the $_[1]: $! \n";
exit;
}
formmail.html -
<HTML>
<HEAD>
<TITLE>Send e-mail to Stephen</TITLE>
</HEAD>
<BODY>
<FORM ACTION="http://www.sitedesigns4u.co.uk/cgi-bin/formmail.cgi" METHOD=POST>
<b><font size=+1>Write an email:</font></b>
<table border=0>
<tr><td align=right>To: </td><td><INPUT TYPE="text" NAME="to"></td></tr>
<tr><td align=right>From: </td><td><INPUT TYPE="text" NAME="from"></td></tr>
<tr><td align=right>Subject: </td><td><INPUT TYPE="text" NAME="subject"></td></tr>
<tr><td align=right>Contents: </td><td><TEXTAREA NAME="contents" ROWS=4 COLS=40></TEXTAREA></td></tr>
<tr><td> </td><td><INPUT TYPE="submit" VALUE="Send e-mail"> <INPUT TYPE="reset" VALUE="Erase e-mail"></td></tr>
</table></FORM>
</BODY>
</HTML>