sfm.cgi/sfm.php

other software from the same author

Features
sfm stands for Simple Form Mail CGI. The CGI needs "sendmail" and "Perl" or "PHP" on your web site. It has no bell nor whistle. You ask your web guest to write a message. The CGI script receives it and converts it to an email and sends it to you. You can replace the address of the recipient to someone other than yourself so that you can send an email without a mailer but from your web site. (But you do not think you can send a spam or anonymous email. Identifying the sender is always possible.)

DownLoad
You can choose either Perl version or PHP version, compressed by LHA, Zip or TAR.GZ. Click to download:
sfm.cgi (LHA), sfm.cgi (Zip) or sfm.cgi (tar.gz).
sfm.php (LHA), sfm.php (Zip) or sfm.php (tar.gz).

Source Code
If you cannot download and open compressed files, or you just want to see the source code, check out the Perl CGI source (sfm_cgi.txt) or the PHP source (sfm_php.txt). To use it, you change the name of CGI source from sfm_php.txt to sfm.php or sfm_cgi.txt to sfm.cgi.

Set up
Since PHP version is much easier to set up, following is mostly for Perl version.

What you must change
Firstly ask your Internet Service Provider where is "Perl" and where is "sendmail". Perl is a computer language and sfm_cgi is written in Perl. Also ask where you can upload CGI script and .htaccess. While some provider let you put CGI anywhere within your directory, others are specific.

Once you get the answers from the provider, open "sfm.cgi" which is nothing but a text document. Use NotePad, a text editor or a word processor. The location of Perl or "Path" must be the first line of CGI - such as #!/usr/bin/perl or #!/usr/local/bin/perl.

To receive an email from your web site, replace 'YOUR@MAIL.ADDRESS' with your mail address. Please note the mail address is put in 'single quote'. Perl treats single quote and double quote differently and @ has special meaning within double quotes.

The sendmail path, as advised by your provider, replaces "/usr/bin/sendmail".

The first few lines of the script are
#!/usr/bin/perl

$addrss = 'YOUR@MAIL.ADDRESS';
$smpath = "/usr/bin/sendmail";

<- change them according to the information given by the provider and by your email address.

Before file upload
You can make other optional changes. Otherwise save the texts. Change carriage return and/or line feed. Mac, Windows and UNIX employ different symbols to tell where a line end (or the return key is pressed). Convert them (a lot of text editors can do this) before you upload sfm.cgi so that your server can understand where the line end. The easiest way of doing this is, however, just forget about the difference and upload files as text (or ASCII) files. They are, indeed, nothing but text files.

You may already have .htaccess in your directly. If so, it must have at least
Options ExecCGI
AddType application/x-httpd-cgi .cgi
AddType application/x-httpd-cgi .cgi/
in it.

The attached file htaccess does not have a dot. If you are a Windows user, you may not able to have a file name .htaccess. Then you have it in other name - the attached file is the example. Upload it, and then rename it to .htaccess.

More, many servers do not show files that begin with a period "." that is .htaccess. If you must have it yet you cannot see it, don't panic. See if the CGI works first. Next, ask your provider.

If your server is not UNIX with certain server program, you may not need .htaccess . Then forget it and follow the direction given by the provider. PC and old Mac handle a file differently.

Permission or file access mask
I assume that you've already made your homepage (if not, do it first) and you know how to upload files. Upload sfm.cgi (and .htaccess if necessary). Then, you set something called permission or file access mask. Usually it can be done by FTP.

Select sfm.cgi and set permission 755 (or -rwxr-xr-x) which means the owner can read/write/execute the file while others can read/execute only. The directory in which you place sfm.cgi needs 755 ( or drwxr-xr-x) and .htaccess is to be set 644 (or -rw-r--r--).

If FTP does not work, ask your provider. You may need to set permission by telnet or you may ask the provider sets permission on behalf of you.

Incidentally you may see the permission a number with four figures instead of three. If so, 755 means 0755, etc.

It's worth to try if any smaller number does the same trick. If you set sfm.cgi 705 instead of 755 and if it works, you can have more security. But I cannot tell if your server allows the CGI works under the tighter security. It all depends on your server. Ask your provider or try and see.

Test run
Once you set the permissions, run a browser. Type the location of sfm.cgi into the browser's location window. And if you can not see the form to send a message, check if sfm.cgi is in the server; the permissions is 755; and check the Perl path is right - no line, no space before #!.

Next, send a message. If successful, you see "thank you" page and get an email before long. If you see "error" message instead, you might click "submit" button without filling the message form. Or maybe you modified the script and made typo.

If you never get an email from sfm.cgi even though you saw "thank you" page, check the mail address and if CGI has right "sendmail" path.

Advanced set up
Besides the above "basic" set up, which is must to have sfm.cgi work, you can change the CGI further. Open sfm.cgi and go down to
### mail start ###
     :
     :
To: $addrss
Subject: Message via sfm.cgi

$data{'MESSAGE'}

To and Subject are standard mail headers. You can have Cc or Bcc or whatever you like here as far as they conform to the mail protocols. Please note, you must have one blank line between the mail head and body to separate them. In the above case, a blank line below Subject:.

You can change the mail subject Message via sfm.cgi by the words of your choice.

You can also change "error" message and "thank you" message. They can be found under
#################
# error message #
#################
and
### thank you message ###
in sfm.cgi. What comes between <HTML> and </HTML> are HTML documents.

You can also change the mail form
#############
# mail form #
#############
     :
     :
<HTML>
     :
     :
<FORM METHOD="POST" ACTION="$ENV{'SCRIPT_NAME'}">
     :
     :
</HTML>
But DO NOT CHANGE <FORM METHOD="POST" ACTION="$ENV{'SCRIPT_NAME'}"> unless you know what you are doing.

A mail from other page
If you want to send a mail, not only from sfm.cg, but also from other web page, open sfm.cgi and copy <FORM ... to </FORM>.
#############
# mail form #
#############
     :
     :
<FORM METHOD="POST" ACTION="$ENV{'SCRIPT_NAME'}">
     :
     :
</FORM>
Replace $ENV{'SCRIPT_NAME'} by the full URL of sfm.cgi starting from http://... and paste the part to the other web page.
<HTML>
<HEAD>
<TITLE>this is not sfm.cgi but other web page</TITLE>
</HEAD>
<BODY>
     :
     :
<FORM METHOD="POST" ACTION="http://... full url to .../sfm.cgi">
     :
     :
</FORM>
     :
     :
</BODY>
<HTML>

METHOD="GET"
The original script is made to work with "POST" method. Some web server do not accept "POST" but allow only "GET". If you cannot use "POST", use "GET". Though it can send only a shorter message.

To use "GET", change
#############
# mail form #
#############
     :
     :
<FORM METHOD="POST" ACTION="$ENV{'SCRIPT_NAME'}">
to
#############
# mail form #
#############
     :
     :
<FORM METHOD="GET" ACTION="$ENV{'SCRIPT_NAME'}">

Modify Perl script
You may even try some real "Perl" scripting. Suppose you add a FORM element asking where the guest comes from and name it COME in # mail form #
#############
# mail form #
#############
     :
     :
<FORM METHOD="POST" ACTION="$ENV{'SCRIPT_NAME'}">
Where do you come from? <INPUT TYPE="TEXT" NAME="COME">
     :
     :
and you have $data{'COME'} in addition to $data{'MESSAGE'} as cgi data. You can place them in the mail body in sfm.cgi. For example
### mail start ###
     :
     :
To: $addrss
Subject: Message via sfm.cgi

$data{'MESSAGE'}
by a guest from $data{'COME'}

You can have many other combinations of INPUT something in # mail form # and $data{'something'} in # mail start #.

You can limit the mail user by checking the IP address, $ENV{'REMOTE_ADDR'} or checking the browser, $ENV{'HTTP_USER_AGENT'}. To ban an IP address, add following line
#!/usr/bin/perl

if ($ENV{'REMOTE_ADDR'} eq '123.456.78.90') {die "You cannot be here";}
$addrss = 'YOUR@MAIL.ADDRESS';
     :
     :

Replace 123.456.78.90 by an IP address you want to prevent writing a mail against you. Also you can have better wording than You cannot be here.

Set up PHP version
Find and change the mail address
<HTML>
     :
     :
<?php
if ($data) {
mail("YOUR@MAIL.ADDRESS", "mail via sfm", "$data");
     :
     :
from YOUR@MAIL.ADDRESS to your mail address.

Upload the script. And it (usually) works.

You may need .htaccess besides the script. The content must be
AddType application/x-httpd-php4 .php
If the PHP is version 3 instead of 4 above, the content is AddType application/x-httpd-php3 .php3 or AddType application/x-httpd-php3 .php.

You may need the directory permission 0777 though sfm.php needs 0644 only.

Warranty
No warranty. (Saying so however, the most of case a software does not work is you do not know or misunderstand how it works. If in trouble, you may go Question and Answer. Tough I do not guarantee you get an answer, nor it's to be right or wrong.)

Links
Have you installed sfm? Visit LazyLinksLimited and register your homepage. LazyLinksLimited is an automatic link page script also made by me.

sfm.cgi, Version 1.5
visitware (C) 1999-2002 B. Uchina, All rights reserved

about visitware
If you use this software, you want to visit my homepage http://www.visitware.com/sobaya/.

A visitware is a free of charge software in which visiting the author's homepage is the condition of usage. A user is obligated to visit the author's homepage at least once except he does not have internet access.

A visitware author registers his name (handle) with visitware.com. He is given free homepage space and assigned URL. URL will be http://www.visitware.com/your name/ in which the author's handle replaces "your name".

A third party can distribute or modify visitware as far as he follows "about visitware". He does not need to pay nor obtain an agreement from the author unless otherwise specified.

A party distributing visitware or a product based on it has to attach the full text of "about visitware" in which address of the homepage to visit is designated and claims and obligations of a user, a distributor, a rewriter or any other parties involved are specified.

The homepage of visitware.com is http://www.visitware.com/, please visit. For further information, please feel free to contact info@visitware.com.



Click Here