Web Hosting Forum | Lunarpages

Author Topic: Setting up NMS FormMail  (Read 86710 times)

leighsww

  • Guest
Setting up NMS FormMail
« on: August 04, 2004, 03:08:11 PM »
*******************************************************************
If you need your results saved to a db or text file, or need file upload/attachment capabilities, then use the TFMail script.

If you just need the results of your form emailed to you, then the NMS FormMail script is a much simpler and faster script to configure.

*******************************************************************

Make sure you have the latest version of the NMS FormMail script.  Here's the link to download the file (it's the first one that says "compat") --> Click here

Here's the changes/customizations you need to make to your configs (I recommend that you print out these instructions so you can follow it step-by-step, checkmarking each step as you finish them, so you do not miss anything):

THE FormMail.pl SCRIPT:

Step 1) Change the name of the script from "FormMail.pl" to anything else you want (you MUST change the name and DO NOT use the words "form", "mail" or "contact" at all in the name, otherwise the script may be disabled by LP due to those words being used).

Step 2) Change the following configs (located at the beginning part of the script with the heading # USER CONFIGURATION SECTION):

Code: [Select]
$mailprog = '/usr/sbin/sendmail -oi -t';
Code: [Select]
@referers = qw(yourdomain.com localhost);
Code: [Select]
@allow_mail_to = qw(user@yourdomain.com localhost);
Code: [Select]
From: user@yourdomain.com
* NOTE: "yourdomain.com" and "user" should be replaced with whatever your domain name and email addy would be.

(If you are on a Windows Server click on this following link --> Click here and change your shebang line and $mailprog configs to what it says in the post - if you're NOT on Windows Server, DO NOT click on that link, cuz it will only confuse you and if you change those settings it will be incorrect  :))


DO NOT touch anything below the CONFIGURATION section (if you do not know perl) and DO NOT remove ANY portion of the coding in the script!!!!!! You need all that stuff after the CONFIGURATION too, so just make the changes shown above, but NO erasing/deleting anything!!

Step 3) Upload the .pl file to your cgi-bin in ASCII (text mode) and chmod (set permissions) to 755 (to set permission via cPanel, follow these instructions --> Click here)


THE HTML FORM:

Step 1) the "action" tag should look like this:

Code: [Select]
<form method="post" action="/cgi-bin/scriptname.pl">
* NOTE: Replace "scriptname" with whatever you named your formmail script to.

Step 2) The field where you want your visitors to enter their email addy must be written as --> email
- this is due to having the sender's email addy in the "From:" section of the email that gets sent to you. If you write it any other way (ex: Email, e-mail, e_mail, etc.) the script will put "nobody@server.lunarpages.com" in the "From:" header of the email.
So, the source code for the form for that tag should look like:

Code: [Select]
<input type="textbox" name="email">
You might also want to make that field "required" so that the Submitter doesn't leave it blank (see Step 3 below for details).

If you are not using separate "first" and "last" names fields, you might want to use "realname" instead of just "name" for the following tag, like so:

Code: [Select]
Your Name: <input type="text" name="realname">
The script uses "realname" in its code which will then put the person's name in the "From:" section of the emailed results instead of just their email addy (their email will still be available to view in the properties and if you do a "reply" it will email to their email addy). Having their name show up instead of only the email addy has its advantages/benefits, especially for referencing purposes.

Step 3) Other hidden tags you may want to add (put these below the "action" tag):

Code: [Select]
<input type="hidden" name="subject" value="Form Submission">
<input type="hidden" name="required" value="email">
<input type="hidden" name="redirect" value="../thankyou.htm">

* NOTE: You replace the values with whatever applicable.

For the "redirect", you can use either a relative path (as shown), or an absolute path (ex: http://yourdomain.com/thankyou.htm). This is the page that the submitter will be taken to once they hit the "submit" button. If you do not put this tag in your form, the script will use their default "Thank You" (it's kinda plain).

For the "required", if you want to have other fields included as well, add to the value string using commas (ex: "email,realname,phone"). This tag is used so the submitter can't leave the field blank.

Step 4) If you've used a previous version of formmail, DO NOT put your email addy in the form under the "recipient" hidden tag, because it's a vulnerability for spam email harvesting (the recipient of the form submissions is in your script under the "@allow_mail_to").
So I repeat, REMOVE the "recipient" hidden tag if you have your email addy in it.

However, if you want to send the form results to multiple email addys or assign different forms to certain email addys, then follow these instructions for the "recipient" hidden tag --> Click here

* Also, scroll down to talloth_endill's post, as he shows how to use it with a drop-down menu/list

TO CONCLUDE ...

If you have successfully tested your script and all is working (no error messages), then you should go back into the CONFIGURATION section of the .pl script and change the following from "1" to "0" as shown below:

Code: [Select]
$DEBUGGING         = 0;
What this does is restrict the amount of information that a malicious person attacking your site can obtain.

If you receive errors after you have configured your script and html file, then:

1) Make sure that you have followed the above instructions EXACTLY, going through each step again to double-check.

2) Read my post in the following thread and check for those problems --> Click here

MISCELLANEOUS ...

If you're new at this, the above configs are all you need to modify for the script and html. However, if you're a little more adventurous/experienced, the "README" file will have other "optional" modifications that can be used/made for various needs. Also, read the "EXAMPLES" file, as well.

IMPORTANT ...

If you have any problems, DO NOT contact LP tech support.  LP's tech support cannot help you (they are not obligated to do so with scripts), due to this is NOT a server-side/web hosting issue, and you will just add unnecessary support tickets to their workload which then puts other customers who really need tech support to wait longer in the queue.

If you need any further help, please DO NOT post in this thread and DO NOT send me a IM/PM (Private Message), because if I'm not available to help you right away, others will be able to, so you need to post in the C++ / PERL / CGI (<-- click on that to go there now) section of the forums.

Your cooperation will be greatly appreciated ... THANK YOU!  :love:)

Okay, that's it  :thumb:
« Last Edit: August 27, 2007, 12:13:16 AM by leighsww »

Offline Webuffy

  • Space Explorer
  • ***
  • Posts: 6
    • http://www.marrsandersen.com
Setting up NMS FormMail
« Reply #1 on: August 13, 2004, 03:10:00 PM »
This is so helpful -- this should really be in the Knowledge Base!

Offline Mordac85

  • Trekkie
  • **
  • Posts: 16
Setting up NMS FormMail
« Reply #2 on: October 16, 2004, 02:06:29 PM »
fwiw,
I just spent a few hours troubleshooting the "Premature end of script headers" error.  I finally found the reference to the stylesheet /css/nms.css  Once I dropped that it started working just fine.

Code: [Select]
$style = '';
~Glenn

Rules of Project Specification:
 - Good
 - Fast
 - Cheap
Pick 2, you can't have all 3!

Offline talloth_endill

  • Galactic Royalty
  • *****
  • Posts: 220
Setting up NMS FormMail
« Reply #3 on: October 17, 2004, 12:07:32 PM »
btw, there is a neat turnaround of an implemented feature i "discovered" setting the script up that, even if evident for many, may be usefull to someone :

the %recipient variable is normally used when you have multiple fomrs on the same website... I use it in conjunction to a select box, so that users can choose one recipient from the list i give.
i.e, the readme file gives this :
Code: [Select]
FROM THE README FILE :
                      %recipient_alias = (
                        '1' => 'one@your.domain',
                        '2' => 'two@your.domain',
                        '3' => 'three@your.domain',
                      );

                      In the HTML form that should submit to the recipient
                      'two@your.domain', you would then set the recipient
                      with:

                      <input type="hidden" name="recipient" value="2" />


but i use the feature using a select box instead of an hidden field to choose the recipient.
ie :
Code: [Select]
in the HTML form to choose one recipient out of a select box :

<select size="1" name="recipient">
<option selected value="1">Webmaster - General question</option>
<option value="2">Coder - Programming question</option>
<option value="3">Designer - Artistic question</option>
</select>



the result here is a select box where the Webmaster choice is on by default, but the user can choose which person he wants to write to depending on what he wants to know... The select box will the pass the recipient value depending on the user's choice to the script, which will choose the corresponding %recipient alias number and send  the mail to the choosen one  :roll:

Hope this is of some use for someone...

See ya all...

Talloth Endill aka Joe
edit : WOW ! i'm a space explorer now !   :abduct:
Luck is my middle name. Mind you, my first name is Bad.

Offline fambi

  • Spacescooter Operator
  • *****
  • Posts: 46
    • http://www.smscomms.com/
Setting up NMS FormMail
« Reply #4 on: October 20, 2004, 07:38:48 AM »
Thanks for that.
Lunarpages provided us with the first ever server for our sms gateway.

Offline kypsah

  • Galactic Royalty
  • *****
  • Posts: 219
    • http://www.kypsah.com
Setting up NMS FormMail
« Reply #5 on: November 20, 2004, 07:31:45 AM »
Just came across a problem with my script.  I need to edit it to where when the person fills out the form correctly, it'll automatically go to a "Success" page where the person knows that the form has been submitted.  Currently, people (once having submitted the form successfully) are receiving HTTP 404--File Not Found.  

Can someone please tell me how to edit this script?  I'm afraid I'll mess it up ;)

Thanks!
Eyes are the windows of the soul, but through the heart, the mouth speaks.

Jessie :)

Offline talloth_endill

  • Galactic Royalty
  • *****
  • Posts: 220
Setting up NMS FormMail
« Reply #6 on: November 20, 2004, 07:39:22 AM »
Hey kypsah,

To achieve this you do not need to edit the script

try to insert the following into your form :
Code: [Select]
<input type="hidden" name="redirect" value="http://www.your.domain/your_success_page.htm" />
Of course, you need to replace the your.domain.com and your_success_page for what is suitable for you.

This should do the trick  :thumb:
Let me know if you need more help

EDIT : if you need more help, please, open a new thread in the CGI Topic. I think it would be better not to mess up the How to section.
Luck is my middle name. Mind you, my first name is Bad.

Offline kypsah

  • Galactic Royalty
  • *****
  • Posts: 219
    • http://www.kypsah.com
Setting up NMS FormMail
« Reply #7 on: November 20, 2004, 08:05:22 AM »
Good point!  I don't want to mess up the section :D  I will insert the code into the form first to see if this works without editing the script.  Thanks!
Eyes are the windows of the soul, but through the heart, the mouth speaks.

Jessie :)

Offline xeon

  • Space Explorer
  • ***
  • Posts: 9
Setting up NMS FormMail
« Reply #8 on: December 09, 2004, 05:23:16 PM »
I have problem with the configuration. I configured this script correctly and its working fine too. The problem is I am getting the email from the "nobody@server.lunarpages.com" email address. I changed the field name to email also. but no success. Anybody can help me for this issue.

leighsww

  • Guest
Setting up NMS FormMail
« Reply #9 on: December 09, 2004, 05:29:35 PM »
Quote from: xeon
I have problem with the configuration. I configured this script correctly and its working fine too. The problem is I am getting the email from the "nobody@server.lunarpages.com" email address. I changed the field name to email also. but no success. Anybody can help me for this issue.
Post a link to your html form, please (do so in the CGI section of the forum and I'll meet you there - do not continue this issue here, thanks!)

Click on this http://www.lunarforums.com/forum/index.php?board=4.0 and create a new thread
« Last Edit: August 06, 2005, 12:13:46 PM by leighsww »

Offline freew4

  • Newbie
  • *
  • Posts: 1
    • http://www.freewheelchairmission.org
Setting up NMS FormMail
« Reply #10 on: May 14, 2005, 07:42:40 AM »
WOW!! I have spent two days and some money too trying to find this information. Even the "program" that I purchased was little more than a huge script file and a huge readme that left me spinning my wheels. After 30 minutes using your SIMPLE and EXACT instructions (4 lines of code only) I have a working script! Why oh why isn't someone selling this????? THANK YOU!!!  :yey:

leighsww

  • Guest
Setting up NMS FormMail
« Reply #11 on: May 14, 2005, 10:17:22 AM »
Quote from: freew4
Why oh why isn't someone selling this????? THANK YOU!!!  :yey:

LOL, because it's FREE!!  :)  :thumb:

Offline sweir

  • Newbie
  • *
  • Posts: 2
    • Faith Baptist Church
Re: Setting up NMS FormMail
« Reply #12 on: August 06, 2005, 11:54:46 AM »

Step 3) Upload the file to your cgi-bin in ASCII (text mode) and chmod (set permissions) to 755


How would one do that? I tried to putty into my site, but no luck. Help?

leighsww

  • Guest
Re: Setting up NMS FormMail
« Reply #13 on: August 06, 2005, 12:23:06 PM »
Here's instructions on how to set the file permission via cPanel:

1) In cPanel, click on "File Manager"
2) Click on the folder icon of the public_html
3) Click on the folder icon of the cgi-bin
4) Click on the  filename of the .pl script file
5) In the upper right-hand corner of your screen, click on "Change Permissions".

The following should be checked marked (R = Read, W = Write, E = Execute):

Owner: R, W, E
Group: R, E
All Users: R, E


Make sure to checkmark the boxes and NOT just type in the numbers. Typing in the numbers will NOT make the changes.

6) Click the "Change" button.

When you finish, make sure that you see the change to 755 has taken place.

Also, if you still are having problems, please DO NOT continue to post in this thread. Please start a new topic in the CGI section and I will help you there --> http://www.lunarforums.com/forum/index.php?board=4.0

« Last Edit: October 06, 2005, 01:31:54 PM by leighsww »

Offline sweir

  • Newbie
  • *
  • Posts: 2
    • Faith Baptist Church
Re: Setting up NMS FormMail
« Reply #14 on: August 06, 2005, 12:53:24 PM »
Thanks! It works! This is a great resource!

 

Share |