Can't use cgiemail


#1

We have 4 forms using cgiemail. On our ex host, they were working fine. On Dreamhost, I haven’t found yet how to make them work. I get this result :
“Not Found. The requested URL /cgi-bin/cgiemail/membre.txt was not found on this server. (While it’s there. I’ve ftp it in Ascii mode.)
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.”

I know formmail.dreamhost.com could do the job, but I would rather keep using cgiemail.

Can somebody help?


#2

I think you need to rename cgiecho to cgiecho.cgi, and rename cgiemail to cgiemail.cgi, and change action in your form to cgiemail.cgi, as said here:

http://web.mit.edu/wwwdev/cgiemail/webmaster.html#install

Also make sure directories and cgi files permissions are 755 and .txt is 644 (I guess).

Test worked for me like this, with testce.html and testce.txt in domain top directory.


$1 for me << [color=#00CC00]SE7ENOF9[/color] | [color=#CC0000]SE7ENOF97[/color] >> All for you


#3

Hi there.

Well I am clearly just not “getting it” when it comes to cgiemail.
And I might add it’s starting to hurt my head.

I recovered a website for a user whose host died completely (as a result of a hack) and they lost everything. I used http://wayback.archive.org/web/ to recover all the pages and graphics, then lots of editing with Notepad++ to put things back together. And now I am hosting it while I try and fix it up.

There is a cgiemail form embedded in one of the pages. I have checked the script embedded in that page and everything seems ok with it… Some of which is -

Obviously the content of cgi-bin and its subfolders are not accessible from the wayback archives.
So I have been reading (heaps) and have downloaded and subsequently uploaded the CGI source files to my www.domainname.com site.

I renamed the cgiemail and cgiecho to add .cgi extension.
I changed the permissions of everything in and under domainname.com/cgi-bin to 755

Whenever I try the form, I click on Send, and all it does is open the text file (the email template .txt file) in a browser.
I normally use Chrome but tried IE as well. No change.

Trying the testce file, same thing happens - all I get to see is the testce.txt file in its raw form, like this…

[quote]From: [required-webmaster]
To: [cgiemail], [required-webmaster]
Subject: [os] cgiemail-[required-release] up in [min] minutes

Comments:
[comments]


[listme]

  • [isp ] [/quote]

    I asked Dreamhost for help with the live chat and they directed me to a relatively useless Wiki page.

    I just found this wiki as well. More in-depth, but I don’t understand a lot of it as well.

    Perhaps I am overlooking something to do with CGI scripts… There’s certainly something that i just don’t “get”.

    Anyone got any advice or essential reading?[hr]
    I just went right back to basic…
    Made a file questions.html
    Content is

    Your e-mail address:


    Your name:


    Your quest:


    Your favourite colour:


    put it in www.domainname.com
    (not my real domain)

    Made a text file questions.txt
    Put it in same place
    Content of that file is

    To: myemailaddress@domainname.com
    Subject: questions three

    What is your name? [yourname]
    What is your quest? [quest]
    What is your favourite colour? [colour]

    Changed permission of both files to 755

    When I visit questions.html and fill in the form and click on Submit, all I see is a web page displaying the content of the file questions.txt exactly as it appears above, without fields being filled in.

    Seriously confused…


  • #4

    You didn’t specify whether or not you compiled the programs - the manual says they are C.

    Also, did you make a /cgi-bin/cgiemail directory and put the template in it? If you did that is why it is not working. You would have to change the path to be /cgi-bin/cgiemail.cgi and put the template file in the /cgi-bin directory. Read about the CGI PATH_INFO environment variable.


    #5

    You’re right - I didn’t mention whether I compiled and made the files, sorry.
    Yes, I did run
    ./compile
    make
    And all went well.

    I just verified I had the bookings_template.txt file in the /cgi-bin folder and they are chmodded to 755
    And I removed the txt file from /cgi-bin/cgiemail folder
    Now I get

    [quote]Not Found

    The requested URL /cgi-bin/cgiemail/bookings_template.txt was not found on this server.

    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.[/quote]
    The thing I don’t get is
    action="http://www.domainname.com/cgi-bin/cgiemail/bookings_template.txt"
    I take it that the CGI magic that goes on just happens to know to look for cgiemail.cgi in the /cgi-bin folder even though the action calls for cgiemail instead of cgiemail.cgi

    I tried changing the action to
    action=“http://www.domainname.com/cgi-bin/cgiemail.cgi/bookings_template.txt

    But I got

    [quote]Internal Server Error

    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Please contact the server administrator, webmaster@domainname.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

    More information about this error may be available in the server error log.

    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.[/quote]

    Going to have a read of
    CGI PATH_INFO environment variable
    now…


    #6

    Try leaving the PATH_INFO value off and simply browse to /cgi-bin/cgiemail.cgi - you should get a message saying it is installed correctly.

    The Internal Server Error (status 500) error message is general and not worth copying and pasting. As it says you should check the server error log - which is found in the logs directory.

    Also most of the time data file permissions should be 644 and not 755. The +1 indicates it is an executable and not just data.


    #7

    This might serve as a tutorial to others…

    Starting from scratch.

    Entirely removed all content from cgi-bin
    Uploaded source files to domainname.com/cgi-bin/
    Chmodded all to 755
    Shell accessed, using Putty and the username and password that was created when the username was created (email from Dreamhost when user was created).
    And configure

    [quote]$ ./configure
    creating cache ./config.cache
    checking cgienv… yes
    checking owner-bounce… no
    checking x-headers… yes
    checking for sendmail… /usr/sbin/sendmail
    checking for gcc… gcc
    checking whether the C compiler (gcc ) works… yes
    checking whether the C compiler (gcc ) is a cross-compiler… no
    checking whether we are using GNU C… yes
    checking whether gcc accepts -g… yes
    checking how to run the C preprocessor… gcc -E
    checking for ANSI C header files… yes
    checking for size_t… yes
    checking for sigprocmask… yes
    checking for strerror… yes
    checking for socket… yes
    updating cache ./config.cache
    creating ./config.status
    creating cgi.h
    creating Makefile
    creating testce.html
    creating config.h
    config.h is unchanged
    [/quote]
    And make

    [quote]$ make
    gcc -c -o cgilib.o cgilib.c
    gcc -c -o cgiemail.o cgiemail.c
    gcc -o cgiemail cgilib.o cgiemail.o
    cgilib.o: In function cgi_mail_template': cgilib.c:(.text+0x15cd): warning: the use oftmpnam’ is dangerous, better use mkstemp' gcc -c -o cgiecho.o cgiecho.c gcc -o cgiecho cgilib.o cgiecho.o cgilib.o: In functioncgi_mail_template’:
    cgilib.c:(.text+0x15cd): warning: the use of tmpnam' is dangerous, better usemkstemp’
    gcc -c -o cgifile.o cgifile.c
    gcc -o cgifile cgilib.o cgifile.o
    cgilib.o: In function cgi_mail_template': cgilib.c:(.text+0x15cd): warning: the use oftmpnam’ is dangerous, better use mkstemp' gcc -DCSOHEADER=\"/afs/net.mit.edu/admin/www/root/csoheader\" -DCSOFOOTER=\"/afs/net.mit.edu/admin/www/root/csofooter\" -c cgilibcso.c gcc -c -o csoget.o csoget.c gcc -c -o cgicso.o cgicso.c gcc -o cgicso cgilib.o cgilibcso.o csoget.o cgicso.o cgilib.o: In functioncgi_mail_template’:
    cgilib.c:(.text+0x15cd): warning: the use of tmpnam' is dangerous, better usemkstemp’
    [/quote]
    Renamed files www.domainname.com/cgi-bin/cgiecho and www.domainname.com/cgi-bin/cgiemail to chiecho.cgi and cgiemail.cgi respectively.
    Checked permissions of those two files - at 755, no change required.

    Checked my action in the web page with the form -
    action="http://www.domainname.com/cgi-bin/cgiemail.cgi/bookings_template.txt"
    Checked my txt file is in the location /cgi-bin/

    Tried it.
    It redirects to my “Success” page, and it now works, I received the email as well.
    So what the blazes was I doing wrong all this time? Clearly, I didn’t have a clue.

    Thank you all very much!

    I was thinking I must have to create a script based on bookings_template.txt but couldn’t find any instruction on that anywhere, but then there is no specific cgi script existing for the testce example installed. Talk about twisting myself in knots!

    UPDATE Before posting, I made all the changes back to the user so they can use it, I found I needed to put bookings_template.txt in www.domainname.com and not in www.domainname.com/cgi-bin/
    Don’t know why that changed, but it works so I don’t care either!

    Thanks again.


    #8

    So now I’ve been looking at what files can be removed from the cgi-bin folder that are not needed.
    I got it down to this list and it still works.

    cgiecho.cgi
    cgiecho.o
    cgiemail.cgi (the important one)
    cgiemail.o
    cgifile
    cgifile.o
    cgilib.o
    cgilibcso.o
    csoget.o

    I just renamed all the others for now but will remove them all as they aren’t needed.
    Which of these don’t I need?
    Should I change the permissions of any of them for security purposes?

    I notice the following 3 are at 775 which I found odd, I thought they should be 755, but I don’t really know.

    cgiecho.cgi
    cgiemail.cgi
    cgifile

    All the others are at 664
    Thoughts?


    #9

    See DreamHost Wiki - Unix File Permissions - What kind of access?