PHP is open source scripting language. It\'s widely used to develop web applications.  Home Web Programming PHP How to make a simple form mailer with PHP

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.



About the Author:

 Rupe Parnell is the founder and lead developer at Starsol.co.uk, a website development and management firm located in Norfolk, England. Rupe specialises in creating PHP scripts that use MySQL databases.
Author's URL: Rupe Parnell
PHP is open source scripting language. It\'s widely used to develop web applications. More PHP Tutorials: Featured Materials | Fresh Materials | More PHP Tutorials at LearnPHP.org

Reader's comments
comments onyeka December 09, 2011 says:
Please someone should teach me how to make a php mailer my email address is giggsrider@yahoo.com
Reply
comments Mr Alone July 01, 2011 says:
Contact me .. databasem6cracker@yahoo.com
I dont share knowledge free
you pay, i teach all you need to know

Reply
comments sameer June 24, 2011 says:
Dear,
please tell me how can i make mailer as soon as possiable
my id is sameer.ycspl@gmail.com

Reply
comments Ajay June 23, 2011 says:
Wonderful post. Thank you for sharing. Have copied the code to check if it really works.
Reply
comments Mailer April 19, 2011 says:
Dear friend
please tell me how can i make mailer form
so that ican post it through the mails

please mail me at
neeraj10786@rediff.com

Reply
comments nicholas March 14, 2011 says:
where do i put username and password for host? help me
Reply
comments adebayo October 31, 2010 says:
how am i going too send mains to email
Reply
comments blonsky amaechi May 23, 2010 says:
i need mailer am amaechi
Reply
comments james March 17, 2010 says:
l need mailer
Reply
Add comments to "How to make a simple form mailer with PHP"

Captcha