1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

HTML form and sendmail

Discussion in 'Software Development' started by big_pimp, Jul 31, 2003.

Thread Status:
Not open for further replies.
Advertisement
  1. big_pimp

    big_pimp Thread Starter

    Joined:
    Jul 1, 2003
    Messages:
    191
    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:

    <form action=mailto:http://www.funliasons.com/usr/sbin/[email protected] method=POST>Name<input type=text name=name maxlength=30><input type="submit" value="Send me your name!"></form>

    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?
     
  2. Shadow2531

    Shadow2531

    Joined:
    Apr 30, 2001
    Messages:
    2,636
    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.

    <form action="sendmail.cgi" method="post">
    <p>
    <label for="from">Enter Your Email Address</label>
    <br />
    <input id="from" type="text" name="from" style="width: 160px;">
    <br />
    <br />
    <label for="message">Type Your Message</label>
    <br />
    <textarea id="message" name="message" rows="20" cols="60" ></textarea>
    <br />
    <input type="submit" value="Send Email" />
    </p>
    </form>


    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)
     
  3. big_pimp

    big_pimp Thread Starter

    Joined:
    Jul 1, 2003
    Messages:
    191
    thx for the form.. but i dont seem to be able to get that to work either .. just get 404's :(
     
  4. panzer999

    panzer999

    Joined:
    Jul 14, 2003
    Messages:
    724
    <html><body>
    <form action="mailto:[email protected]" method="post">
    <p>
    <label for="from">Enter Your Email Address</label><br />
    <input type="text" name="from" style="width: 160px;"/><br /><br />
    <label for="message">Type Your Message</label><br />
    <input type="textbox" name="message" style="width: 400px; height: 200px;" />
    <br />
    <input type="submit" value="Send me mail!">
    </p>
    </form>

    :)
     
  5. big_pimp

    big_pimp Thread Starter

    Joined:
    Jul 1, 2003
    Messages:
    191
    err wont that just open outlook express
     
  6. Shadow2531

    Shadow2531

    Joined:
    Apr 30, 2001
    Messages:
    2,636
    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.
     
  7. CyBerAliEn

    CyBerAliEn

    Joined:
    Nov 25, 2001
    Messages:
    1,209
    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/
     
  8. bassetman

    bassetman Moderator (deceased) - Gone but never forgotten

    Joined:
    Jun 7, 2001
    Messages:
    47,973
    Here is one I have used, that doesn't need a CGI file:
     
  9. Shadow2531

    Shadow2531

    Joined:
    Apr 30, 2001
    Messages:
    2,636
    CyBerAliEn, thanks, I understand. (y)
     
  10. big_pimp

    big_pimp Thread Starter

    Joined:
    Jul 1, 2003
    Messages:
    191
    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?
     
  11. big_pimp

    big_pimp Thread Starter

    Joined:
    Jul 1, 2003
    Messages:
    191
    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?
     
  12. bassetman

    bassetman Moderator (deceased) - Gone but never forgotten

    Joined:
    Jun 7, 2001
    Messages:
    47,973
    Make sure the Save As is set to all files. Otherwise it adds the .txt to it.
     
  13. big_pimp

    big_pimp Thread Starter

    Joined:
    Jul 1, 2003
    Messages:
    191
    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
     
  14. bassetman

    bassetman Moderator (deceased) - Gone but never forgotten

    Joined:
    Jun 7, 2001
    Messages:
    47,973
    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.
     
  15. big_pimp

    big_pimp Thread Starter

    Joined:
    Jul 1, 2003
    Messages:
    191
    hehe nice 1 thx
     
  16. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/151494

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice