Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
April 23, 2014, 01:51:16 AM

Pages: [1]   Go Down
  Print  
Author Topic: Setting up the TFMail script  (Read 22256 times)
Priest
Darth Vader
Support Supervisor
Quantum Encyclopedia Writer
*****
Offline Offline

Posts: 3862



WWW
« on: March 05, 2004, 01:54:17 PM »

OK, I've decided to re-write this based on some issues I've been seeing while helping people set up their TFMail scripts.  A few notes about this tutorial first.  Text that appears in blue is text that you will need to change.  This is most likely things like usernames or passwords.  Text that appears in red are notes that are important along the way.

With that out of the way, here we go.

1.)  Download the TFMail.zip file here: http://nms-cgi.sourceforge.net/tfmail.zip

2.)  Extract the files

3.)  Rename TFmail.pl to anythingelse.pl (I will continue to use TFmail.pl, just substitute whatever you named the file.  Also, be sure when you rename the file that it does not have the word mail or contact in it)

4.)  Rename TFmail_config to anythingelse_config.pl (I will continue to use TFmail_config.pl, just substitute whatever you named the file.  Also, be sure when you rename the file that it does not have the word mail or contact in it)

5.)  Open Notepad (or your preferred text editor) and then open TFmail.pl.  Configure it so that it looks like the one below (Note that where it says username you will need to put in your lunarpages account name).  When you have finished, save the file.
Code:
use constant DEBUGGING      => 0;
use constant LIBDIR         => '/home/username/tfmail/lib';
use constant MAILPROG       => '/usr/sbin/sendmail -oi -t';
use constant POSTMASTER     => 'webmaster@yourdomain.com';
use constant CONFIG_ROOT    => '/home/username/tfmail/cfg';
use constant SESSION_DIR  =>  '.';
use constant MAX_DEPTH      => 0;
use constant CONFIG_EXT     => '.trc';
use constant TEMPLATE_EXT   => '.trt';
use constant ENABLE_UPLOADS => 0;
use constant USE_MIME_LITE  => 1;
use constant LOGFILE_ROOT   => '/home/username/tfmail/log';
use constant LOGFILE_EXT    => '.log';
use constant HTMLFILE_ROOT  => '/public_html';
use constant HTMLFILE_EXT   => '.html';
use constant CHARSET        => 'iso-8859-1';

6.)  open TFmail_config.pl.  Configure it so that it looks like the one below (Note that the file has many more lines than those listed here and those lines should not be removed) (Note that where it says username you will need to put in your lunarpages account name and where it says yourpassword you will need to enter any password you want).  When you have finished, save the file.
Code:
use constant DEBUGGING      => 0;
use constant LIBDIR         => '/home/username/tfmail/lib';
use constant CONFIG_ROOT    => '/home/username/tfmail/cfg';
use constant CONFIG_EXT     => '.trc';
use constant LOGFILE_ROOT   => '/home/username/tfmail/log';
use constant LOGFILE_EXT    => '.log';
use constant CHARSET        => 'iso-8859-1';

# The file that the script should use as a lock file and a
# place to count failed password attempts.  This should not
# be the name of an existing file - the script will create
# the file itself.
use constant LOCKFILE       => '.lock';

# Set the password to some word or phrase that nobody will be
# able to guess.  It's important to choose a strong password
# as anybody who guesses it will be able to take control of
# your web site and use your web server to attack other hosts
# on the internet.
use constant PASSWORD       => 'yourpassword';

7.)  Connect to yourdomain.com and create a folder called tfmail in the root directory (This is the same directory that mail, public_ftp, public_html, etc. is in.  Do not create this folder inside public_html).  Inside the tfmail folder create a cfg folder, a lib folder, and a log folder.

8.)  Upload the following files to the directories specified.  Don't worry about any leftover files, they can be safely deleted (Make sure that your FTP client is in ASCII mode when you upload these files).
  • TFmail.pl and TFmail_config.pl => /public_html/cgi-bin
  • NMSTreq.pm, NMSCharset.pm, and MIME_Lite.pm => /tfmail/lib
9.)  Using either your FTP software or the File Manager in CPanel, change the permissions on TFmail.pl and TFmail_config.pl to 755.

10.)  Open your web browser and go to http://www.yourdomain.com/cgi-bin/TFmail_config.pl

11.) Type in the password you entered above

12.)  We are now given a series of forms.  The first is the main configuration box.  It will look like this:
Code:
%% NMS configuration file %%
#
# TFmail configuration.
#

#
# recipient: the email address(s) to which TFmail should
# send the results of the form submission.
#
recipient: your.email@address.goes.here

#
# The names of the CGI inputs that TFmail should use to
# build the From: header of the email.
#
email_input:    email
realname_input: realname

We will want to modify it to look like this to begin with, but see the notes below as this is where many people get lost:
Code:
%% NMS configuration file %%
#
# TFmail configuration.
#

#
# recipient: the email address(s) to which TFmail should
# send the results of the form submission.
#
recipient: email@yourdomain.com

#
# The names of the CGI inputs that TFmail should use to
# build the From: header of the email.
#
email_input:    Email
realname_input: Name
# What the "Subject" field will contain
subject:  Subject of your email


# Which fields are required:
required: Name, Email, Phone

# What the "Subject" field will contain in the confirmation e-mail:
confirmation_subject: Confirmation subject

# What external page to show as the success page,
# if you don't use the success_page template
#redirect:  http://www.domain.org/tfmail_success.htm

# Name of the logfile:
logfile: name of logfile

# Format of the log and which fields to use:
log_template:%{= date =} | {= env.REMOTE_ADDR =} | {= param.Name =} | {= param.Email =} | {= param.Phone =} | {= param.Comments =}

OK, first thing you will need to do is put your email address where it says recipient.  This is the email address that will be receiving the information.  Then change the subject and confirmation_subject to whatever you would like them to be.  Finally, change logfile to whatever you want, but the filename should not have an extension on it (eg mylog instead of mylog.log).

Now then, the email_input, realname_input and required sections and the ones that start with param.  Let's say the code for your web page looks something like this:
Code:
<FORM METHOD="POST" ACTION="/cgi-bin/TFmail.pl">
<INPUT TYPE="TEXTBOX" NAME="Real_Name">
<INPUT TYPE="TEXTBOX" NAME="Email">
<INPUT TYPE="TEXTBOX" NAME="Comments">
<INPUT TYPE="SUBMIT" VALUE="Send">
<INPUT TYPE="RESET" VALUE="Clear">
</FORM>

Then in the configuration file, you would have this:
Code:
email_input: Email
realname_input: Real_Name

required: Email, Real_Name

log_template:%{= date =} | {= env.REMOTE_ADDR =} | {= param.Real_Name =} | {= param.Email =} | {= param.Comments =}

You can change the values depending on the input you request from the visitor.  The names that you would enter here will be the same as the names of the textboxes from your HTML form.  The required section means those particular input boxes must be filled in by the visitor and the log_template section is what will be stored in the logfile.

13.)  The next box is the confirmation template.  It is what the visitor received through email when the form is submitted with no errors.  You can leave it unchanged, or add a customized message like below.
Code:
Thank you for sharing your thoughts about my website with me.

14.)  The third box is the email that you will receive ( The same rules that applied in the first box relating to the param. items can be used in the third, fourth, and fifth boxes as well).  Below is a sample of how yours could look.
Code:
Below is the result of your feedback form.  It was submitted
{= by_submitter =}on {= date =}.
----------------------------------------------------------------------

My name is {= param.Real_Name =} and I can be reached at {= param.Email =}.

Here is what I thought of your site:
{= param.Comments =}

15.)  The next box is the missing template.  This is a web page that is displayed if the visitor left something out that you required (back in the first box).  You can pretty much leave it the way that it is.

16.)  The last box is the success box.  It means they entered everything ok  and you both will be getting an email.  You can leave it the way it is or spruce it up a little.

17.)  Down at the very bottom, type in a name for the rules that we just created.  I recommend, especially if you have more than one submit form, that you name it something that is related to what the form does (ie you have an email contact form, name the rule contact).  Then click Save this Configuration.

18.)  If all went well, you should see the following box:
Code:
The configuration contact was saved successfully.

To use the configuration you have just saved, ensure that your HTML form includes the following:

<input type="hidden" name="_config" value="contact" />

19.)  Finally let's modify our web page to add the line it made for us.
Code:
<FORM METHOD="POST" ACTION="/cgi-bin/TFmail.pl">
<INPUT TYPE="TEXTBOX" NAME="Real_Name">
<INPUT TYPE="TEXTBOX" NAME="Email">
<INPUT TYPE="TEXTBOX" NAME="Comments">
<input type="hidden" name="_config" value="contact">
</FORM>

20.)  That's it, everything should be working fine now.

I hope this has helped some of you out.  If you have any feedback or suggestions, feel free to PM me.  If you have any errors or need assistance, please post in the forums Thumbs Up
« Last Edit: October 01, 2008, 11:57:03 PM by Priest » Logged

Lunarpages Web Hosting ~ Lunarpages Forums ~ Lunarpapages Affiliate Program

Steven Priest
Customer Services Supervisor, Technical Support
Geeky Perl Aficionado
College Guy

For all the things I cannot change...™
Pages: [1]   Go Up
  Print  
 
Jump to: