Help with HTML

jfall

Diamond Member
Oct 31, 2000
5,975
2
0
I am trying to make one of those forms where someone can type in a message and then submit it, it sends VIA e-mail. I don't want the form to open up the persons e-mail program and send the message from there, I want the server to send the message automatically when submit is pressed. Does anyone know how I can do this? I'm pretty sure that i'm going to have to use CGI, is there any places that offer this for free? just to use for sending e-mail?
 

Buddha Bart

Diamond Member
Oct 11, 1999
3,064
0
0
here.. i don't remember the details of it, but we had to do that for scripting class.
Go here and scroll to the bottom. That mailit4.pl is the perl cgi script. You should be able to figure it out from those.

bart
 

yllus

Elite Member & Lifer
Aug 20, 2000
20,577
432
126
Right, a fairly short CGI script should do this for you. Let me throw together a quick one and see how it looks:

-- copy from the next line on --

#!/usr/local/bin/perl
# Variables defined here.
$mailprog = '/usr/lib/sendmail';
$host = 'yourreplyaddress@domain.com';

# Get the sender's name, message subject and e-mail address from the form.
$name = "$FORM{'name'}";
$subject = "$FORM{'subject'}";
$email = "$FORM{'email'}";
$ipaddy = "$ENV{'REMOTE_ADDR'}";

# Assign the body of text from the form to a variable.
$body = "$FORM{'body'}";

# Send the e-mail off.
open (MAIL, "|$mailprog $email") || die "Can't open $mailprog!\n";
print MAIL "From: $host\n";
print MAIL "Subject: $subject\n";
print MAIL "Reply-To: $host\n\n";
print MAIL "$body\n";
print MAIL " \n";
print MAIL "This message was from the following address: $ENV{'REMOTE_HOST'} ($ENV{'REMOTE_ADDR'}).\n";
close (MAIL);

-- end of script --

You might want to add on some code that gives indication that the e-mail was sent successfully. Do some light reading on CGI/Perl and edit things as needed, but you should only really need to edit the very first line and the variable $host. Of course, you'll need a small HTML form to draw all those variables from as well. ;) PM me for additional help.
 

jfall

Diamond Member
Oct 31, 2000
5,975
2
0
With CGI script, do you have to put it on the web server? i'm trying to do this without using my server itself, I want it to either do it by itself, or use a free service to send the message
 

Fardringle

Diamond Member
Oct 23, 2000
9,200
765
126
You really don't even have to use a CGI script if you are just going to have it submitted via email. I have tested this form in several different versions of windows, with several different versions of MS Outlook and Netscape Messenger, and none of them ever actually opened the email client other than the "Sending Message" box which immediately closes itself once the form has been sent...

To do this in standard HTML and have the form sent directly to your email address without any further processing required on the hosting server, just put the following lines into your page:

At the top of the form to be submitted:
<form METHOD=&quot;POST&quot; ACTION=&quot;mailto:<your email address>&quot;>

At the bottom of the form to be submitted:
<input TYPE=&quot;SUBMIT&quot; VALUE=&quot;Get Quote&quot; ><input TYPE=&quot;RESET&quot; VALUE=&quot;Reset Form&quot;>

(Note, for this example, the &quot;Get Quote&quot; should be changed to whatever you want your &quot;SUBMIT&quot; button text to say, and you can choose whether or not to include the &quot;RESET&quot; button, but it's an easy way for the user to start over with a clean form if they should want to.)

For an example of how this works, try this form I made for a local insurance agency: Homeowner's Insurance Quote Form


edit: Fixed the link...
 

jfall

Diamond Member
Oct 31, 2000
5,975
2
0
I have coded it the way you said, it still brings up the mail program, the weird thing is that it brings up the mail program to a new message window but there is nothing typed in the subject or body field.
 

jfall

Diamond Member
Oct 31, 2000
5,975
2
0
Also.. the problem is with submitting through the persons own e-mail account is that it is suppose to be anonymous.. so it can't show the persons e-mail address that is submitting the form.

I'll tell you exactly what i'm trying to do, you will understand it better this way:

I am making this form for a company that I work for, in this company we have a CRC (company relations committee) which is a committee which listens to concerns of it's employees and then discusses them and makes decisions on them. I'm making the form so that employees can fill out their question/concerns and it sends it to the CRC e-mail address. It has to be 100% anonymous, so it can't be sent using the e-mail client on the employees computer because it will show the employees e-mail address.