Using PHP Forms to send e-mail (PHP FormMail)

contact_usIn my day to day role working with LCN as a 2nd line support engineer I have been exposed to a wide range of customer requests, from the basic password reset to ensuring web and email servers are running as they should . However the one issue that seems to pop up more often than not is the use of PHP forms to send emails, and enabling them to work on our hosting servers.

The creation of a PHP FormMail can be quite a daunting task to the uninitiated, it is for this reason that I have decided to provide a few basic answers to some questions you may be faced with when creating a PHP FormMail (in relation to an LCN hosting anyway). The links provided in this blog will give you a beginners guide on creating your first PHP Form Mail, I certainly hope you find it useful.

What is a PHP FormMail and how does it work?

So first of all, what is it? a PHP FormMail is a very useful tool that is used to collect information entered into it from end users/customers of a website. This information is then e-mailed to the website owner. Information such as a customers name, e-mail address, contact telephone number and comments about the website are commonly included in the PHP FormMail. By far the most common examples are ‘feedback’ and ‘contact us’ forms.

To give a very basic technical point of view, I’ll give a basic break down of the three elements to the PHP FormMail

PHP FormMail

Basically PHP is the coding used to make your PHP Form mail. It stands for Hypertext Preprocessor and it’s a scripting language widely used to design websites which use dynamic content. php runs on the vast majority of our web servers and can be utilised on our Dynamic and Premium Hosting packages.

For further information about php visit: http://www.lcn.com/admin/faqs/what-is-php

PHP FormMail

The form is exactly what it says it is; the only difference is it’s an online form that can be created in php or html located on your webpage/website, that like any other form has been designed to collect information entered into it by the person who is filling it out .

PHP FormMail

Once the information has been entered into the form by the end user, and the submit button is clicked, the results are parsed through a script and is emailed to you with through the use of a php script.

What versions of PHP can I use?

Currently our servers are running php ver.5.2.6.

So all versions of php from 4.0 to 5.2.6 are supported.

How do I get started creating my own php FormMail?

The following websites provide sound advice on how to create a basic php FormMail using the popular sendmail.php script and there are some example scripts you can use.

http://www.w3schools.com/PHP/php_mail.asp

http://www.thesitewizard.com/archive/feedbackphp.shtml

http://www.ibdhost.com/contact/

What is sendmail ?

Sendmail is basically the email routing facility running on the server, that is responsible for sending the email.

The sendmail path that you will need to put in your sendmail.php script is:  /usr/sbin/sendmail

Troubleshooting the script

Writing your own more complex bespoke script may prove to be time consuming and a matter of trial and error at times! It is however, a very self satisfying achievement once you’ve created a finished working script. We do actively encourage you to persevere with your scripts, even if they do not work first time round.  Bug fixing or troubleshooting a script can also be a time consuming exercise, this is often the reason why designers are employed to create these specific pages for website owners.  Try not to give up too early if your find your script does not work straight away, it is sometimes the simple instructions that are overlooked.

I hope you have found this blog article useful, I certainly welcome any feedback and comments below.  The information I have provided in this article should be sufficient to get you started, or will have at least provided you with a better insight into its use.  Should you decide to create a MailForm of your own, remember that there is a wealth of information available to you on the Internet.  Google is your friend!

Happy scripting.

2 Responses to “Using PHP Forms to send e-mail (PHP FormMail)”

  1. ceadsgororigo

    ceadsgororigo Says:

    December 31st, 2009 at 8:38 pm

    Sry for being OFFTOPIC but what WordPress template are you using? It’s looking cool!

  2. boost

    boost Says:

    January 7th, 2010 at 10:49 pm

    It’s a custom built template, we’re glad you like it. Thanks for the feedback.

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>