# HTML form and sendmail



## big_pimp (Jul 1, 2003)

i really lost with making a form to send me an email thru cgi sendmail

ok well i've tried a few variations but well i think it might be easier if someone can help me if i give u this info

cgi sendmail function is thru

www.mysite.com/usr/sbin/sendmail

i made a very simple form:

Name

now dont laugh at me for being stupid this is my first try and spent an hour looking around the web but i cant find how to do it.. this is just bringing me up to a 404 page what am i doing wrong?


----------



## Shadow2531 (Apr 30, 2001)

I don't know how sendmail works, but I will offer some generic help.

If I was going to set up a form and cgi script to have visitors send me mail, I would first have an html page called sendmail.html, with a form like below. Sendmail.html would be in the same directory as sendmail.cgi. Sendmail.cgi would be the cgi script used to grab the query string variables submitted by the form and pass them on to the sendmail program.

Enter Your Email Address

Type Your Message

Then when you click submit, the actual uri being submitted would be

http://www.funliasons.com/usr/sbin/[email protected]&message=I%20see%20you

Then the cgi program would grab the 2 variables "from" and "message".

Then the cgi program would pass it on to sendmail and send the mail. The email address it sends the messages to, should be set in the cgi program, and not in the form code. So your email address should be on some line in the cgi code I would think. If not, I would be able to send people mail using your cgi script by plugging in a different email address. You could have the cgi program automatically set a subject or have a subject box in the form.

That's how I think it would work.

Maybe that will help. (If not, enjoy the form)


----------



## big_pimp (Jul 1, 2003)

thx for the form.. but i dont seem to be able to get that to work either .. just get 404's


----------



## panzer999 (Jul 14, 2003)

Enter Your Email Address

Type Your Message


----------



## big_pimp (Jul 1, 2003)

err wont that just open outlook express


----------



## Shadow2531 (Apr 30, 2001)

Yeh, it will send it through outlook express, but maybe that was the point.

Instead of having a form and the whole sendmail thing, just let people use their mail client to send you email.

Anyways, where is the location of your cgi script?

I tried a bunch of different locations and kept getting the 404 error. However, if I put 
http://www.funliasons.com/sendmail.cgi I get a different error.

I get the error because there is no sendmail.cgi in the root of your directory, but the fact that I get the cgi file not found error might mean that in your case, cgi might be setup for the root of your directory.

It also looks like cgi might not even be setup.

I think we'll need more info.

What is the file name for the cgi script?
Where is it located?
Allow us to look at the code of the script.

You should make a test cgi script so we can see if cgi is working.

*#!/usr/bin/perl

print "Content-type: text/html\n\n";
print "Hello World!\n";*

save that as test.cgi

Put it in the root of your directory and your bin folder if you have one.

Even if the path to perl is wrong, we should at least get a cgi error or something.

If we could see the source of the sendmail script, we could see what variables need to be passed in the form.


----------



## CyBerAliEn (Nov 25, 2001)

First of all, sendmail is basically the "function" used to send the email. It isn't used directly with the form. What you need is another CGI script that actually processes the form (the script uses sendmail to actually send it).

These scripts are called "form processing scripts" basically. You can find free ones on the internet (URLs of different directories below for form processors). If your good with CGI, you might be able to make your own script.

You will also want to check the "readme" coming with the form processor as you may need to CHMOD certain files (unlikely), upload to CGI-BIN, etc.

http://www.icthus.net/CGI-City/scr_forms.shtml
http://www.hotscripts.com/Perl/Scripts_and_Programs/Form_Processors/index.html
http://cgi.resourceindex.com/Programs_and_Scripts/Perl/Form_Processing/


----------



## bassetman (Jun 7, 2001)

Here is one I have used, that doesn't need a CGI file:


> [/CENTER]
> I can help Joe put a *mailing* together.
> ...
> 
> ...


​


----------



## Shadow2531 (Apr 30, 2001)

CyBerAliEn, thanks, I understand. :up:


----------



## big_pimp (Jul 1, 2003)

hey bassettman thx for the post that's simular to a form i tried .. it's good in that it will use the form i made but it still uses outlook express..

shadow the path for my sendmail is:

www.funliasons.com/usr/sbin/sendmail

that just comes up with a 404 but i think that's normal isn't it?

what i was basically wondering if i have sendmail is there anyway i can write in html form the email adress i want the form to be sent to?

and that it could use the cgi sendmail function or is this something that has to be done in cgi?. i'm just about to cheack the pages cyber alien put i will get back on that one thx for all ur posts guys..

also does anyone know a good tutorial site on php?


----------



## big_pimp (Jul 1, 2003)

er another quick question... i tried one of the sites cyber gave me.. i have to make a cgi file.. i tried this in notepad put it on 
file type: all files
and saved as testing.cgi

yet it keeps saving as testing.cgi.txt errr how can i create a cgi file?


----------



## bassetman (Jun 7, 2001)

Make sure the Save As is set to all files. Otherwise it adds the .txt to it.


----------



## big_pimp (Jul 1, 2003)

yeah i did .. but its still saving as .cgi.txt for some reason i rebooted and tried again but still the same

but i did it online with my site used one of the email things that cyber posted .. now i get another error so im giving up for now just going to use outlook express


----------



## bassetman (Jun 7, 2001)

WHat prog are you using to make it? * (Oops sorry I just saw it now).
You could right click and Rename and just hack off the .txt on the end.


----------



## big_pimp (Jul 1, 2003)

hehe nice 1 thx


----------



## CyBerAliEn (Nov 25, 2001)

Sorry if you haven't gotten it to work yet.

Every form processor is different, although they generally do the same thing (just in different ways, formats, etc). I would personally suggest you make your own script to do it if you know how to.

Generally with a form processor you will download a ZIP containing the CGI file and hopefully a Readme (may have more files). You will need to read through the included Readme to see how to "install it" and use it.


----------



## big_pimp (Jul 1, 2003)

i used one of the links u gave me.. the host im paying for says they support cgi.. however i've seen on those sites that u gave me that all my cgi has to be in the cgi-bin.. it seems i cant access this in anyway whatsoever.. maybe i'm just stupid lol ..

i did the 3rd one down .. on the second link u gave me.. i havent changed anything except the address it is sent to... supposedly my srver is also ok with perl

i put this page here...

http://www.funliasons.com/tessssting

however the page it sends to after i just get....
CGIWrap Error: Execution of this script not permitted 
Execution of (/home/sites/site145/web/formmail.pl) is not permitted for the following reason:

Script file not found.

i saved a formail.cgi and a formail.pl it said i could do either but i get the same each time


----------



## big_pimp (Jul 1, 2003)

my server has all this:


:: 300MB Web Space
:: 20 POP3 Mailboxes
:: Autoresponder On Each POP3
:: 6000 MB Per Month Data Transfer
:: 10 Sub-domains
:: Free 128 Bit SSL Secure Server
:: Free Domain Name Transfer
:: 24/7 FTP Access
:: Graphical Web Site Statistics
:: Customised Error Pages
:: Password Protected Directories
:: Technical Support
:: CGI-bin & Perl
:: PHP4 Scripting
:: Server Side Includes (SSI)
:: Multi High Capacity Connections
:: 99.5% Uptime
:: 30 Day Money Back Guarantee 

:: Web Based Control Panel
:: mySQL 3 Database Server
:: phpMyAdmin (Database Admin)
:: MS FrontPage2000 Extensions
:: State Of The Art Data Centre 
:: ASP server


----------



## Shadow2531 (Apr 30, 2001)

You could try php instead of using perl, since php will probably work in your root.

Put the following in notepad, save it as test.php and upload it.

<?php phpinfo(); ?>

If you use php, you will still have to setup a php script to grab the variables and pass them onto sendmail.

The path to sendmail might be usr/sbin/sendmail, which is the path you would use in your php script to pass everything on to sendmail.

From all the features you get with your host, they should be telling you how to do it. I would be asking. Not just ask if cgi is set up, but ask them to setup an example and test it for you.

When you log in to your webspace with an ftp client, what folders do you have in there? Do you have a cgi-bin folder? If not, you can make one and give it a shot.


----------



## CyBerAliEn (Nov 25, 2001)

First of all, the error you are getting is saying something about:

*/home/sites/site145/web/formmail.pl*

Try uploading the CGI script to */home/sites/site145/cgi-bin* as this would be your CGI-BIN. If you do not see a CGI-BIN in *site145* then try seeing if there is one at */home/sites/site145/web/cgi-bin*. If there is a folder called *bin*, this is _not_ your CGI-BIN.


----------



## big_pimp (Jul 1, 2003)

i do not have a cgi-bin i'm not sure if this is something that i should have or i should create? both under site 145 or web


----------



## Shadow2531 (Apr 30, 2001)

Here is the info for your webspace server.

That show exactly what versions of everything are running.


----------



## bassetman (Jun 7, 2001)

That partial form script I showed you doesn't need a cgi script to run. Disadvantage is its not a secure sript (if you need that).


----------



## CyBerAliEn (Nov 25, 2001)

The form bassetman showed looks like the following:


```
<form action="mailto:[email protected]" method="POST">

Form fields and etc go in here.

</form>
```
The problem with the above is that if a user does not have email setup on their computer (IE, they use Hotmail or some other web-based email), they won't be able to send the form. Another problem with it is when they submit the form, a dialog box comes up asking basically confirmation to send the form via email; visitors can say no/cancel/etc and the form won't send.

It would appear that you do not have a CGI-BIN. Contact your web host and ask them where it is located and/or have them set one up for you.

Another alternative is PHP. According to the info for your web host, you can use PHP. With PHP, you can place the file wherever you want (in side *web*, in *web/scripts*, etc. Below are some directories for PHP form processors. Again, you will want to check the README file included to see what you need to do with the script.

http://www.hotscripts.com/PHP/Scripts_and_Programs/Form_Processors/index.html
http://www.scriptsearch.com/PHP/Scripts_and_Programs/Form_Processing/


----------



## bassetman (Jun 7, 2001)

This bit


> ENCTYPE="text/plain">


 added to the above can make a big difference too.


----------

