Site5 - Built For Designers & Developers MENU
Home  ›  Email  ›  Email: Create a Contact Form using Formmail

Email: Create a Contact Form using Formmail

26 Comments

In this article, we will show you how to setup and configure Form Mail, a perl based email script that is an excellent alternative to cPanel’s FormMail scripts. It will allow you to have the results of html forms sent to you via email.

For this article, you will need to know basic html, and ftp.

1) Download the newest copy of the Form Mail script from http://www.scriptarchive.com/download.cgi?s=formmail

2) Unzip the archive and open the FormMail.pl file using your preferred text editor (e.g. notepad).

3) Edit the following settings located at the top of the file…

locate:

$mailprog = '/usr/lib/sendmail -i -t';

… and replace with:

$mailprog = '/usr/sbin/sendmail -i -t';

Now locate:

@referers = ('scriptarchive.com','72.52.156.109');

… and replace with:

@referers = ('yourdomain.com');

Note: Make sure that you replace yourdomain.com with your actual domain name.

Once you have made the changes, save the file.

4) Using FTP, upload the saved file from step 3 to the cgi-bin for your website (normally found at public_html/cgi-bin).

5) Still using FTP, change the permissions of the FormMail.pl file to allow it to be executable (e.g. 0755). For more information about permissions and CHMOD, please click here.

6) Open the file you wish to place the contact form on and paste the following code.

<form id=”contact” name=”contact” method=”POST” action=”/cgi-bin/FormMail.pl”>

<label>Your Email: </lable><input type=text name=”email” /><br />
<label>Subject: </lable><input type=text name=”subject”/><br />
<label>Message: </lable><textarea name=”body” id=”body” cols=”45″ rows=”5″></textarea><br />

<input type=hidden name=”recipient” value=”[email protected]” />
<input type=hidden name=”redirect” value=”http://yourdomain.com/thankyou.html“/>
<input type=”submit” name=”button” id=”button” value=”Send” />

</form>

Now we will cover what each line does…

<label>Your Email: </lable><input type=text name=”email” /><br />

This line is where they would input their email so you can reply to them.

<label>Subject: </lable><input type=text name=”subject”/><br />

This gives them the option to input a subject for their email.

<label>Message: </lable><textarea name=”body” id=”body” cols=”45″ rows=”5″></textarea><br />

Here is where they can type a message.

<input type=hidden name=”recipient” value=”[email protected]” />

This is where the email will be sent. Please keep in mind that the domain for the email must be in the @referers section of line 3.

<input type=hidden name=”redirect” value=”http://yourdomain.com/thankyou.html“/>

This line allows you to change where they are redirected after the email has been sent. For example, you could redirect them to a “Thank You” page letting them know their email was sent.

<input type=”submit” name=”button” id=”button” value=”Send” />

This is the button that sends the form. You can change the button text by modifying the value.

That’s it! You now know how to use Form Mail. For more detailed information about what you can do with this form processeser, please read the README file located in the zip file downloaded in step 1. Remember to change the items in bold above to fit your needs.

 

Still have a question? Or need help?
If you need technical support with your account, please email us or chat live with a representative.

26 Comments

  • Why are you all using/publishing a script that hasnt been updated in 4 years?

    • Hello Al,

      Thank you for the great comment!

      The Formmail software we used in this article, while old, is still a powerful form processer that many people still use.

      We are in the process of putting together a PHP form processer that we will release on the KnowledgeBase soon.

      If you have any other questions, please feel free to leave a reply here, or if you prefer, you can contact our support team directly by opening a ticket through Backstage.

      Happy Hosting!

      • I beg to differ John. Any form script that exposes the email address is ancient, and weak at best.

        Tectite has a very secure php form for free.
        http://www.tectite.com/fmdoc/index.php

        One only need to configure 2 settings for it to work. Yet the Tectite php script has a HUGE array of options for both security and receiving convenience.

        It also offers a paid online configurator for $10. Gives you two days make all the forms you want. The form is free, you paying for the convenience of the auto configuration.
        http://www.tectite.com/wizards/choose.php

        Spits out 3 forms one can use, and the ready to go Tectite script.

        For the experienced, free download, and self-configure.
        http://www.tectite.com/formmail.zip

        • Hello Al,

          Thank you for passing that along. However, we are not stressing the use of FormMail over any other script – this is a question that comes up often in our support department from customers, and we have written this guide as a way to help. This is not us telling people to use FormMail, but simply helping those of our customers who choose to do so.

          • Please avoid using this formmail. It’s a scam.

            I installed this script. When you submit, it will take you to another website.

            Please avoid at all cost. Moderator, please try it out and delete Al’s post.

            • You simply didn’t configure the “results page.” So take that!

            • I see nothing wrong witht he links, they are all Tectite.

          • James,

            Regardless of the lack of security and other shortcomings, we know that site owners continue to use this script and others like it. We warn our clients not to use any of these. We use an internally-developed ISAPI application that encodes the sender’s email address and posts the sender’s message directly to a database on our server (if the filters show it is not spam).

            We would expect and hope to see more of these types of solutions in the future.

            • Hi Glenn,

              That is fine, yes. As mentioned elsewhere here, having this guide is not a tacit suggestion to use this script. We have many customers who ask about this script specifically, and we put this guide together to aid them. All of our customers are free to use whatever form script they wish to use, provided it works on our servers (and most do).

  • I am beginning the process of adding a simple custom order form to my website to handle some initial order processing.

    I reviewed the KB and jsut anted to ask if this form is customizable? I woudl want to add some other input fields and have a label be part of the form. Can we use other scripts and a custom php.ini file?

    • Hello Justin,

      I hope this reply finds you well!

      You can add as many fields as you wish to the HTML form. Simply format them like you would any other form field.

      If you have any questions, please feel free to leave a comment here, or if you prefer, you can contact our support team directly by opening a ticket through Backstage.

  • I think the correct tag is “label” not “lable”, right?

    • Hi Melissa,

      You are correct, yes, and this has been edited accordingly. Thanks for pointing that out!

  • Is there any kind of phishing/spam protection on this? I want to change my form mail to this one, but the problem with my old one is that I’m always getting spam/bot mail from it.

  • Hello Reony,

    Not by default, no. But you can certainly add a CAPTCHA to your form to help with this – http://www.google.com/recaptcha/captcha

    This forces your form to be used by a human rather than a bot.

    • Oh right! Thanks for reminding me about this. I think when I tried it once in the past I couldn’t get it to work with my current form template. Maybe if I use your Form mail with this it will.

  • Inspiring!, Thanks for the info…. Cheers :)

  • Why do you use a script that displays your email address for spammers to get?

  • Is there an input field to have a user upload a file, and how would the file be handled (i.e. mailed with form as an attachment, loaded to a sub-directory, etc)?

    • Hi John,

      Not with this formmail script, no. At least, not by default. I am sure you could add the code for this, but I am not certain how well it would work. For something like that, I would recommend looking for another form script with that functionality built-in.

  • I did not think you could use recaptcha with html but had to be php
    I have php email script but client has users that always put double and single quotes in the comment box that are legitimate and relevant to commenting on sizes in feet and inches but the email response the get replaces the double quotes and single quotes with html entities…I have tried using htmlentities in the php script to allow the quotation marks to no avail.

    • That does sound quite strange, but there is nothing server-side that would cause that, that I am aware of. That would be in the code itself, and something you may want to have a developer look at.

  • Hi John Oliver,

    Can the Contact Form validate E-mail and Physical Address the users type in?

    • Hi there,

      I am not entirely sure what you mean. Are you asking if the form script will confirm an accurate email and physical address when entered, to ensure it is correct? If so, no, this will not happen. I am sure it could be done, but not with this simple script – the code to do this would be large and quite complicated.

  • Hi James,

    Thank you for your reply. That was what I was asking about.

  • Nice guide and form mail seems really easy to use.

Money Back Guarantees