How to make a simple form mailer with PHP

How to make a simple form mailer with PHPAs you may be well aware, displaying your e-mail address on your website can lead to e-mail harvesters picking up your address and adding it to hundreds or even thousands of lists used by spammers. If you want to allow your website visitors to contact you, but do not want to publicly display your e-mail address, then a form mailer may be exactly what you are looking for.

What is a form mailer? Quite simply, it is a form that you place on your website, that when filled in and submitted, sends you an e-mail with the contents. Below is an example of a simple form mailer written in PHP - feel free to change the information to that of your own website and make use of it:

[WRITE YOUR HTML HEADER HERE]

<?php

if ($_POST[t] == 'process'){

mail('webmaster@yoursite.tld','Your Site Contact Form Submission',stripslashes($_POST[message]),'FROM:'.$_POST[email]);

echo'<p>Thank you, your message was sent to the webmaster.</p>'."n";

} else {

echo'<form action="'.$_SERVER[PHP_SELF].'" method="post">'."n";
echo'<input type="hidden" name="t" value="process"></input>'."n";
echo'Your E-Mail Address:<br /><input type="text" name="email" size="30" value=""></input><br /><br />'."n";
echo'Your Message:<br /><textarea name="message" cols="30" rows="8"></textarea><br /><br />'."n";
echo'<input type="submit" value="Send E-Mail"></input>'."n";
echo'</form>';
}

?>

[WRITE YOUR HTML FOOTER HERE]

To clarify, copy and paste everything from [WRITE YOUR HTML HEADER HERE] to [WRITE YOUR HTML FOOTER HERE] into a text editor such as Notepad. Make your desired alterations. Save as a file with a .php extension (such as contact.php). Upload to your server and link to the file.

If you are in need to any professional grade custom PHP scripts, please see Starsol Scripts at Starsol.co.uk Scripts.


Related Articles

  • What is the Best Methods of Sending Free Traffic to Your Website?
    Besides stunning web design, content is really what will be appreciated by your visitors. Read about benefits of article marketing.
  • Simple Contact Form
    Learn how to write a clean and easy contact form for your site.
  • Form Mail via CDONTS
    ASP gives you the power to send mail using the CDONTS mail object. This script will send an email from a user to whichever email address you choose...
  • E-mail form using HTML and PHP
    Sometimes its a nice touch to include an e-mail feedback form on your contact page or elsewhere on your web site. Lets create an e-mail form using html and a simple php script to send it along.
  • Form Handling
    We are going to be working with the $_Post or $_Get arrays. They basically tell the form if i needs to post something, or get something. In this case we are going to be showing you the basics of a contact email form, so we will be using the $_Post array.
  • The Importance of Having a Feedback Form in Your E-commerce Website
    Internet marketing is a different ball game altogether when compared to traditional marketing. A brick and mortar store employs salespersons to guide and advise its customers. No such equivalent of a salesperson exists for an online store. This could be one of the reasons why people shy away from on...
  • PHP Contact Form
    First, lets create the html section. I made a simple form, but it gets the job done. You can customize it if you want, but remember to use the same form variables.
  • Form Validation
    Learn the different ways of validating your form with Javascript.
  • Inserting Rows into a Database
    This tutorial will show you how to insert a row of data into a database using ASP and an MS Access database. You can do it on one ASP file, but well have two files: one processor page (proc.asp), and one form page (form.asp). Then, well make the MS Access database that corresponds to the ASP.
  • PHP:Form Series: Validators & Client-side Validation
    This tutorial is really helpful to those of us who are a little intimidated by PHP:form. All of those hard to answer questions are easily explained in this simple to use educational web page. Hope you enjoy!

Contact Web Design Outsource and get started today

Need Website Designing, Development, Redesigning, Maintenance and SEO services or help growing your company's web presence? Request a free Quote Now.