Creating an HTML Form That Accepts Mail-Related Information

Submitted by:Jhon Brain

Date added:19 November, 2011


HTML Form using php code that accepts mail related information

Tags: php email

Code Snippet:

<title>Simple Send Mail Form</title>
<h1>Mail Form</h1>
<form name="form1" method="post" action="SimpleEmail.php">
<tr><td><b>To</b></td><td><input type="text" name="mailto" size="35"></td></tr>
<td><input type="text" name="mailsubject" size="35"></td></tr>
<td><textarea name="mailbody" cols="50" rows="7"></textarea></td>
<tr><td colspan="2">
<input type="submit" name="Submit" value="Send">

<!-- SimpleEmail.php
if (empty ($mailto) ) {
die ( "Recipient is blank! ") ;

if (empty ($mailsubject) ){
$mailsubject=" " ;

if (empty ($mailbody) ) {
$mailbody=" " ;

$result = mail ($mailto, $mailsubject, $mailbody) ;

if ($result) {
echo "Email sent successfully!" ;
echo "Email could not be sent." ;